fix: rebuild dynamic routes cache on server restart

follow up on #4525
pull/4600/head
Divyansh Singh 7 months ago
parent 7a9ae34a3a
commit 9f54714e7d

@ -130,7 +130,7 @@ export async function resolveConfig(
userConfig, userConfig,
sitemap: userConfig.sitemap, sitemap: userConfig.sitemap,
buildConcurrency: userConfig.buildConcurrency ?? 64, buildConcurrency: userConfig.buildConcurrency ?? 64,
...(await resolvePages(srcDir, userConfig, logger)) ...(await resolvePages(srcDir, userConfig, logger, true))
} }
// to be shared with content loaders // to be shared with content loaders

@ -70,8 +70,14 @@ export function defineRoutes(loader: RouteModule) {
export async function resolvePages( export async function resolvePages(
srcDir: string, srcDir: string,
userConfig: UserConfig, userConfig: UserConfig,
logger: Logger logger: Logger,
rebuildCache = false
): Promise<Pick<SiteConfig, 'pages' | 'dynamicRoutes' | 'rewrites'>> { ): Promise<Pick<SiteConfig, 'pages' | 'dynamicRoutes' | 'rewrites'>> {
if (rebuildCache) {
moduleGraph = new ModuleGraph()
routeModuleCache.clear()
}
// Important: tinyglobby doesn't guarantee order of the returned files. // Important: tinyglobby doesn't guarantee order of the returned files.
// We must sort the pages so the input list to rollup is stable across // We must sort the pages so the input list to rollup is stable across
// builds - otherwise different input order could result in different exports // builds - otherwise different input order could result in different exports

Loading…
Cancel
Save