Fix index normalizing for app outputs (#11099)

This ensures we don't apply the index output normalizing for app paths which was previously already gated for prerenders but not all routes.
This commit is contained in:
JJ Kasper
2024-01-31 14:13:23 -08:00
committed by GitHub
parent 3bad73401b
commit 4027a18337
7 changed files with 92 additions and 23 deletions

View File

@@ -2053,6 +2053,11 @@ export const onPrerenderRoute =
let isAppPathRoute = false;
// experimentalPPR signals app path route
if (appDir && experimentalPPR) {
isAppPathRoute = true;
}
// TODO: leverage manifest to determine app paths more accurately
if (appDir && srcRoute && (!dataRoute || dataRoute?.endsWith('.rsc'))) {
isAppPathRoute = true;
@@ -2184,7 +2189,6 @@ export const onPrerenderRoute =
if (routeKey !== '/index' && routeKey.endsWith('/index')) {
routeKey = `${routeKey}/index`;
routeFileNoExt = routeKey;
origRouteFileNoExt = routeKey;
}
}
@@ -2255,15 +2259,20 @@ export const onPrerenderRoute =
const lambdaId = pageLambdaMap[outputSrcPathPage];
lambda = lambdas[lambdaId];
} else {
const outputSrcPathPage = normalizeIndexOutput(
let outputSrcPathPage =
srcRoute == null
? outputPathPageOrig
: path.posix.join(
entryDirectory,
srcRoute === '/' ? '/index' : srcRoute
),
isServerMode
);
);
if (!isAppPathRoute) {
outputSrcPathPage = normalizeIndexOutput(
outputSrcPathPage,
isServerMode
);
}
lambda = lambdas[outputSrcPathPage];
}
@@ -2464,11 +2473,18 @@ export const onPrerenderRoute =
routesManifest,
locale
);
const localeOutputPathPage = normalizeIndexOutput(
path.posix.join(entryDirectory, localeRouteFileNoExt),
isServerMode
let localeOutputPathPage = path.posix.join(
entryDirectory,
localeRouteFileNoExt
);
if (!isAppPathRoute) {
localeOutputPathPage = normalizeIndexOutput(
localeOutputPathPage,
isServerMode
);
}
const origPrerenderPage = prerenders[outputPathPage];
prerenders[localeOutputPathPage] = {
...origPrerenderPage,
@@ -2969,14 +2985,17 @@ export async function getMiddlewareBundle({
}
if (routesManifest?.basePath) {
shortPath = normalizeIndexOutput(
path.posix.join(
'./',
routesManifest?.basePath,
shortPath.replace(/^\//, '')
),
true
const isAppPathRoute = !!appPathRoutesManifest[shortPath];
shortPath = path.posix.join(
'./',
routesManifest?.basePath,
shortPath.replace(/^\//, '')
);
if (!isAppPathRoute) {
shortPath = normalizeIndexOutput(shortPath, true);
}
}
worker.edgeFunction.name = shortPath;