0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
* closes #4633

* chore: add changeset
This commit is contained in:
Tony Sullivan 2022-10-04 16:16:47 +00:00 committed by GitHub
parent 67099805f4
commit 4f73b98ae0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes a bug that logged route cache warnings in `astro dev`

View file

@ -5,6 +5,7 @@ import type {
GetStaticPathsResultKeyed,
Params,
RouteData,
RuntimeMode,
} from '../../@types/astro';
import { debug, LogOptions, warn } from '../logger/core.js';
@ -77,9 +78,11 @@ export interface RouteCacheEntry {
export class RouteCache {
private logging: LogOptions;
private cache: Record<string, RouteCacheEntry> = {};
private mode: RuntimeMode;
constructor(logging: LogOptions) {
constructor(logging: LogOptions, mode: RuntimeMode = 'production') {
this.logging = logging;
this.mode = mode;
}
/** Clear the cache. */
@ -91,7 +94,7 @@ export class RouteCache {
// NOTE: This shouldn't be called on an already-cached component.
// Warn here so that an unexpected double-call of getStaticPaths()
// isn't invisible and developer can track down the issue.
if (this.cache[route.component]) {
if (this.mode === 'production' && this.cache[route.component]) {
warn(
this.logging,
'routeCache',

View file

@ -436,7 +436,7 @@ export default function createPlugin({ settings, logging }: AstroPluginOptions):
return {
name: 'astro:server',
configureServer(viteServer) {
let routeCache = new RouteCache(logging);
let routeCache = new RouteCache(logging, 'development');
let manifest: ManifestData = createRouteManifest({ settings }, logging);
/** rebuild the route cache + manifest, as needed. */
function rebuildManifest(needsManifestRebuild: boolean, file: string) {