Unverified Commit 5261ed8d authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack Build: Fix /index/index handling (#80413)

## What?

Alternative for #80385
parent fba3b9b0
...@@ -478,22 +478,29 @@ export class TurbopackManifestLoader { ...@@ -478,22 +478,29 @@ export class TurbopackManifestLoader {
} }
const sortedPageKeys = getSortedRoutes(pagesKeys) const sortedPageKeys = getSortedRoutes(pagesKeys)
const content: ClientBuildManifest = { const clientBuildManifest: ClientBuildManifest = {
__rewrites: normalizeRewritesForBuildManifest(rewrites) as any, __rewrites: normalizeRewritesForBuildManifest(rewrites) as any,
...Object.fromEntries( ...Object.fromEntries(
sortedPageKeys.map((pathname) => [ sortedPageKeys.map((pathname) => {
pathname, let filePath
[`static/chunks/pages${pathname === '/' ? '/index' : pathname}.js`], if (pathname === '/') {
]) filePath = '/index.js'
} else if (pathname.endsWith('/index')) {
filePath = `${pathname}/index.js`
} else {
filePath = `${pathname}.js`
}
return [pathname, [`static/chunks/pages${filePath}`]]
})
), ),
sortedPages: sortedPageKeys, sortedPages: sortedPageKeys,
} }
const buildManifestJs = `self.__BUILD_MANIFEST = ${JSON.stringify( const clientBuildManifestJs = `self.__BUILD_MANIFEST = ${JSON.stringify(
content clientBuildManifest
)};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()` )};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`
await writeFileAtomic( await writeFileAtomic(
join(this.distDir, 'static', this.buildId, '_buildManifest.js'), join(this.distDir, 'static', this.buildId, '_buildManifest.js'),
buildManifestJs clientBuildManifestJs
) )
await writeFileAtomic( await writeFileAtomic(
join(this.distDir, 'static', this.buildId, '_ssgManifest.js'), join(this.distDir, 'static', this.buildId, '_ssgManifest.js'),
......
...@@ -15234,11 +15234,10 @@ ...@@ -15234,11 +15234,10 @@
"nested index.js production mode should ssr page /index", "nested index.js production mode should ssr page /index",
"nested index.js production mode should ssr page /index/index", "nested index.js production mode should ssr page /index/index",
"nested index.js production mode should ssr page /index/project", "nested index.js production mode should ssr page /index/project",
"nested index.js production mode should ssr page /index/user" "nested index.js production mode should ssr page /index/user",
],
"failed": [
"nested index.js production mode should follow link to /index/index" "nested index.js production mode should follow link to /index/index"
], ],
"failed": [],
"pending": [ "pending": [
"nested index.js development mode should 404 on /index/index/index", "nested index.js development mode should 404 on /index/index/index",
"nested index.js development mode should client render page /", "nested index.js development mode should client render page /",
...@@ -16895,11 +16894,10 @@ ...@@ -16895,11 +16894,10 @@
}, },
"test/integration/prerender-export/test/index.test.js": { "test/integration/prerender-export/test/index.test.js": {
"passed": [ "passed": [
"SSG Prerender export production mode export mode should copy prerender files and honor exportTrailingSlash" "SSG Prerender export production mode export mode should copy prerender files and honor exportTrailingSlash",
],
"failed": [
"SSG Prerender export production mode export mode should navigate between pages successfully" "SSG Prerender export production mode export mode should navigate between pages successfully"
], ],
"failed": [],
"pending": [], "pending": [],
"flakey": [], "flakey": [],
"runtimeError": false "runtimeError": false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment