mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
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:
5
.changeset/nasty-teachers-wave.md
Normal file
5
.changeset/nasty-teachers-wave.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@vercel/next": patch
|
||||
---
|
||||
|
||||
Fix index normalizing for app outputs
|
||||
@@ -1128,11 +1128,11 @@ export async function serverBuild({
|
||||
);
|
||||
});
|
||||
}
|
||||
let outputName = path.posix.join(entryDirectory, pageNoExt);
|
||||
|
||||
let outputName = normalizeIndexOutput(
|
||||
path.posix.join(entryDirectory, pageNoExt),
|
||||
true
|
||||
);
|
||||
if (!group.isAppRouter && !group.isAppRouteHandler) {
|
||||
outputName = normalizeIndexOutput(outputName, true);
|
||||
}
|
||||
|
||||
// If this is a PPR page, then we should prefix the output name.
|
||||
if (isPPR) {
|
||||
@@ -1443,9 +1443,10 @@ export async function serverBuild({
|
||||
continue;
|
||||
}
|
||||
|
||||
const pathname = normalizeIndexOutput(
|
||||
path.posix.join('./', entryDirectory, route === '/' ? '/index' : route),
|
||||
true
|
||||
const pathname = path.posix.join(
|
||||
'./',
|
||||
entryDirectory,
|
||||
route === '/' ? '/index' : route
|
||||
);
|
||||
|
||||
if (lambdas[pathname]) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
7
packages/next/test/fixtures/00-app-dir-no-ppr/app/dynamic-index/[slug]/index/page.js
vendored
Normal file
7
packages/next/test/fixtures/00-app-dir-no-ppr/app/dynamic-index/[slug]/index/page.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<p>dynamic-index</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -18,7 +18,22 @@
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
{
|
||||
"path": "/dynamic-index/hello/index",
|
||||
"status": 200,
|
||||
"mustContain": "dynamic-index"
|
||||
},
|
||||
{
|
||||
"path": "/dynamic-index/hello/index",
|
||||
"status": 200,
|
||||
"mustContain": ":",
|
||||
"mustNotContain": "<html",
|
||||
"headers": {
|
||||
"RSC": 1,
|
||||
"Next-Router-Prefetch": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/rewritten-to-dashboard",
|
||||
"status": 200,
|
||||
"mustContain": "html"
|
||||
|
||||
7
packages/next/test/fixtures/00-app-dir-ppr/app/dynamic-index/[slug]/index/page.js
vendored
Normal file
7
packages/next/test/fixtures/00-app-dir-ppr/app/dynamic-index/[slug]/index/page.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<p>dynamic-index</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -18,6 +18,21 @@
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/dynamic-index/hello/index",
|
||||
"status": 200,
|
||||
"mustContain": "dynamic-index"
|
||||
},
|
||||
{
|
||||
"path": "/dynamic-index/hello/index",
|
||||
"status": 200,
|
||||
"mustContain": ":",
|
||||
"mustNotContain": "<html",
|
||||
"headers": {
|
||||
"RSC": 1,
|
||||
"Next-Router-Prefetch": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/rewritten-to-dashboard",
|
||||
"status": 200,
|
||||
|
||||
Reference in New Issue
Block a user