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(
|
if (!group.isAppRouter && !group.isAppRouteHandler) {
|
||||||
path.posix.join(entryDirectory, pageNoExt),
|
outputName = normalizeIndexOutput(outputName, true);
|
||||||
true
|
}
|
||||||
);
|
|
||||||
|
|
||||||
// If this is a PPR page, then we should prefix the output name.
|
// If this is a PPR page, then we should prefix the output name.
|
||||||
if (isPPR) {
|
if (isPPR) {
|
||||||
@@ -1443,9 +1443,10 @@ export async function serverBuild({
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathname = normalizeIndexOutput(
|
const pathname = path.posix.join(
|
||||||
path.posix.join('./', entryDirectory, route === '/' ? '/index' : route),
|
'./',
|
||||||
true
|
entryDirectory,
|
||||||
|
route === '/' ? '/index' : route
|
||||||
);
|
);
|
||||||
|
|
||||||
if (lambdas[pathname]) {
|
if (lambdas[pathname]) {
|
||||||
|
|||||||
@@ -2053,6 +2053,11 @@ export const onPrerenderRoute =
|
|||||||
|
|
||||||
let isAppPathRoute = false;
|
let isAppPathRoute = false;
|
||||||
|
|
||||||
|
// experimentalPPR signals app path route
|
||||||
|
if (appDir && experimentalPPR) {
|
||||||
|
isAppPathRoute = true;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: leverage manifest to determine app paths more accurately
|
// TODO: leverage manifest to determine app paths more accurately
|
||||||
if (appDir && srcRoute && (!dataRoute || dataRoute?.endsWith('.rsc'))) {
|
if (appDir && srcRoute && (!dataRoute || dataRoute?.endsWith('.rsc'))) {
|
||||||
isAppPathRoute = true;
|
isAppPathRoute = true;
|
||||||
@@ -2184,7 +2189,6 @@ export const onPrerenderRoute =
|
|||||||
if (routeKey !== '/index' && routeKey.endsWith('/index')) {
|
if (routeKey !== '/index' && routeKey.endsWith('/index')) {
|
||||||
routeKey = `${routeKey}/index`;
|
routeKey = `${routeKey}/index`;
|
||||||
routeFileNoExt = routeKey;
|
routeFileNoExt = routeKey;
|
||||||
origRouteFileNoExt = routeKey;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2255,15 +2259,20 @@ export const onPrerenderRoute =
|
|||||||
const lambdaId = pageLambdaMap[outputSrcPathPage];
|
const lambdaId = pageLambdaMap[outputSrcPathPage];
|
||||||
lambda = lambdas[lambdaId];
|
lambda = lambdas[lambdaId];
|
||||||
} else {
|
} else {
|
||||||
const outputSrcPathPage = normalizeIndexOutput(
|
let outputSrcPathPage =
|
||||||
srcRoute == null
|
srcRoute == null
|
||||||
? outputPathPageOrig
|
? outputPathPageOrig
|
||||||
: path.posix.join(
|
: path.posix.join(
|
||||||
entryDirectory,
|
entryDirectory,
|
||||||
srcRoute === '/' ? '/index' : srcRoute
|
srcRoute === '/' ? '/index' : srcRoute
|
||||||
),
|
);
|
||||||
isServerMode
|
|
||||||
);
|
if (!isAppPathRoute) {
|
||||||
|
outputSrcPathPage = normalizeIndexOutput(
|
||||||
|
outputSrcPathPage,
|
||||||
|
isServerMode
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
lambda = lambdas[outputSrcPathPage];
|
lambda = lambdas[outputSrcPathPage];
|
||||||
}
|
}
|
||||||
@@ -2464,11 +2473,18 @@ export const onPrerenderRoute =
|
|||||||
routesManifest,
|
routesManifest,
|
||||||
locale
|
locale
|
||||||
);
|
);
|
||||||
const localeOutputPathPage = normalizeIndexOutput(
|
let localeOutputPathPage = path.posix.join(
|
||||||
path.posix.join(entryDirectory, localeRouteFileNoExt),
|
entryDirectory,
|
||||||
isServerMode
|
localeRouteFileNoExt
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isAppPathRoute) {
|
||||||
|
localeOutputPathPage = normalizeIndexOutput(
|
||||||
|
localeOutputPathPage,
|
||||||
|
isServerMode
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const origPrerenderPage = prerenders[outputPathPage];
|
const origPrerenderPage = prerenders[outputPathPage];
|
||||||
prerenders[localeOutputPathPage] = {
|
prerenders[localeOutputPathPage] = {
|
||||||
...origPrerenderPage,
|
...origPrerenderPage,
|
||||||
@@ -2969,14 +2985,17 @@ export async function getMiddlewareBundle({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (routesManifest?.basePath) {
|
if (routesManifest?.basePath) {
|
||||||
shortPath = normalizeIndexOutput(
|
const isAppPathRoute = !!appPathRoutesManifest[shortPath];
|
||||||
path.posix.join(
|
|
||||||
'./',
|
shortPath = path.posix.join(
|
||||||
routesManifest?.basePath,
|
'./',
|
||||||
shortPath.replace(/^\//, '')
|
routesManifest?.basePath,
|
||||||
),
|
shortPath.replace(/^\//, '')
|
||||||
true
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isAppPathRoute) {
|
||||||
|
shortPath = normalizeIndexOutput(shortPath, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
worker.edgeFunction.name = shortPath;
|
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": [
|
"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",
|
"path": "/rewritten-to-dashboard",
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"mustContain": "html"
|
"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": [
|
"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",
|
"path": "/rewritten-to-dashboard",
|
||||||
"status": 200,
|
"status": 200,
|
||||||
|
|||||||
Reference in New Issue
Block a user