[next] App Pages Prerender Manifest Update (#10978)

Previously routes that did not have a `dataRoute` key in the `prerender-manifest.json` would be treated as an App Route. The logic has been updated (for partial prerendering support) to also consider the new `prefetchDataRoute`. Entries with either of these keys are treated as an App Page instead of an App Route.

This also addressed the scenerio where a app route (`route.ts`) with a dynamic segment (`/api/[slug]/route.ts`) which doesn't emit a `.body` during build doesn't cause the build to fail by checking for the file first.
This commit is contained in:
Wyatt Johnson
2023-12-19 14:03:18 -07:00
committed by GitHub
parent 471bdd5b45
commit 7b0adf371b
2 changed files with 18 additions and 4 deletions

View File

@@ -2108,14 +2108,22 @@ export const onPrerenderRoute =
} else if (
appDir &&
!dataRoute &&
!prefetchDataRoute &&
isAppPathRoute &&
!(isBlocking || isFallback)
) {
const contentType = initialHeaders?.['content-type'];
htmlFsRef = new FileFsRef({
fsPath: path.join(appDir, `${routeFileNoExt}.body`),
contentType: contentType || 'text/html;charset=utf-8',
});
// If the route has a body file, use it as the fallback, otherwise it may
// not have an associated fallback. This could be the case for routes that
// have dynamic segments.
const fsPath = path.join(appDir, `${routeFileNoExt}.body`);
if (fs.existsSync(fsPath)) {
htmlFsRef = new FileFsRef({
fsPath,
contentType: contentType || 'text/html;charset=utf-8',
});
}
} else {
htmlFsRef =
isBlocking || (isNotFound && !static404Page)