parent
67099805f4
commit
4f73b98ae0
3 changed files with 11 additions and 3 deletions
5
.changeset/lemon-pets-sneeze.md
Normal file
5
.changeset/lemon-pets-sneeze.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes a bug that logged route cache warnings in `astro dev`
|
|
@ -5,6 +5,7 @@ import type {
|
||||||
GetStaticPathsResultKeyed,
|
GetStaticPathsResultKeyed,
|
||||||
Params,
|
Params,
|
||||||
RouteData,
|
RouteData,
|
||||||
|
RuntimeMode,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import { debug, LogOptions, warn } from '../logger/core.js';
|
import { debug, LogOptions, warn } from '../logger/core.js';
|
||||||
|
|
||||||
|
@ -77,9 +78,11 @@ export interface RouteCacheEntry {
|
||||||
export class RouteCache {
|
export class RouteCache {
|
||||||
private logging: LogOptions;
|
private logging: LogOptions;
|
||||||
private cache: Record<string, RouteCacheEntry> = {};
|
private cache: Record<string, RouteCacheEntry> = {};
|
||||||
|
private mode: RuntimeMode;
|
||||||
|
|
||||||
constructor(logging: LogOptions) {
|
constructor(logging: LogOptions, mode: RuntimeMode = 'production') {
|
||||||
this.logging = logging;
|
this.logging = logging;
|
||||||
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clear the cache. */
|
/** Clear the cache. */
|
||||||
|
@ -91,7 +94,7 @@ export class RouteCache {
|
||||||
// NOTE: This shouldn't be called on an already-cached component.
|
// NOTE: This shouldn't be called on an already-cached component.
|
||||||
// Warn here so that an unexpected double-call of getStaticPaths()
|
// Warn here so that an unexpected double-call of getStaticPaths()
|
||||||
// isn't invisible and developer can track down the issue.
|
// isn't invisible and developer can track down the issue.
|
||||||
if (this.cache[route.component]) {
|
if (this.mode === 'production' && this.cache[route.component]) {
|
||||||
warn(
|
warn(
|
||||||
this.logging,
|
this.logging,
|
||||||
'routeCache',
|
'routeCache',
|
||||||
|
|
|
@ -436,7 +436,7 @@ export default function createPlugin({ settings, logging }: AstroPluginOptions):
|
||||||
return {
|
return {
|
||||||
name: 'astro:server',
|
name: 'astro:server',
|
||||||
configureServer(viteServer) {
|
configureServer(viteServer) {
|
||||||
let routeCache = new RouteCache(logging);
|
let routeCache = new RouteCache(logging, 'development');
|
||||||
let manifest: ManifestData = createRouteManifest({ settings }, logging);
|
let manifest: ManifestData = createRouteManifest({ settings }, logging);
|
||||||
/** rebuild the route cache + manifest, as needed. */
|
/** rebuild the route cache + manifest, as needed. */
|
||||||
function rebuildManifest(needsManifestRebuild: boolean, file: string) {
|
function rebuildManifest(needsManifestRebuild: boolean, file: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue