mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
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,
|
||||
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',
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue