From 623f79493b3c3855b524014b28a2d0ec9619544c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 22 Sep 2025 14:41:05 +0200 Subject: [PATCH 1/4] Turbopack: Make order of routes in prerender manifest deterministic --- packages/next/src/build/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index 68c7034f998fb..373530c10cd5f 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -2818,6 +2818,10 @@ export default async function build( ) ) + const sortedStaticPaths = Array.from(staticPaths.entries()).sort( + ([a], [b]) => (a < b ? -1 : a > b ? 1 : 0) + ) + const exportApp = (require('../export') as typeof import('../export')) .default as typeof import('../export').default @@ -2885,7 +2889,7 @@ export default async function build( // TODO: output manifest specific to app paths and their // revalidate periods and dynamicParams settings - staticPaths.forEach((routes, originalAppPath) => { + sortedStaticPaths.forEach(([originalAppPath, routes]) => { const appConfig = appDefaultConfigs.get(originalAppPath) const isDynamicError = appConfig?.dynamic === 'error' @@ -3054,7 +3058,7 @@ export default async function build( await fs.unlink(serverBundle) } - staticPaths.forEach((prerenderedRoutes, originalAppPath) => { + sortedStaticPaths.forEach(([originalAppPath, prerenderedRoutes]) => { const page = appNormalizedPaths.get(originalAppPath) if (!page) throw new InvariantError('Page not found') From 6a017d793f142ee04f3860a6fcb8474e19619e36 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 22 Sep 2025 14:47:44 +0200 Subject: [PATCH 2/4] Write the same package.json content to distDir --- packages/next/src/build/turbopack-build/impl.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/next/src/build/turbopack-build/impl.ts b/packages/next/src/build/turbopack-build/impl.ts index fbe9ddf977794..8d5e51706a3fd 100644 --- a/packages/next/src/build/turbopack-build/impl.ts +++ b/packages/next/src/build/turbopack-build/impl.ts @@ -104,13 +104,7 @@ export async function turbopackBuild(): Promise<{ }) await fs.writeFile( path.join(distDir, 'package.json'), - JSON.stringify( - { - type: 'commonjs', - }, - null, - 2 - ) + '{"type": "commonjs"}' ) // eslint-disable-next-line @typescript-eslint/no-unused-vars From cbd7c4880de1fad01766c9d136ec1ffc1fcf4735 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 22 Sep 2025 15:04:14 +0200 Subject: [PATCH 3/4] Turbopack: fix output directory for postcss/webpack loaders entrypoint --- crates/next-api/src/project.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/next-api/src/project.rs b/crates/next-api/src/project.rs index ed264f21a8d87..13cd7600f03fe 100644 --- a/crates/next-api/src/project.rs +++ b/crates/next-api/src/project.rs @@ -815,9 +815,9 @@ impl Project { let node_execution_chunking_context = Vc::upcast( NodeJsChunkingContext::builder( self.project_root_path().owned().await?, - node_root.clone(), + node_root.join("build")?, self.node_root_to_root_path().owned().await?, - node_root.clone(), + node_root.join("build")?, node_root.join("build/chunks")?, node_root.join("build/assets")?, node_build_environment().to_resolved().await?, From 6e7e3d3f17cfd34e194c00e37188c37fd52ee679 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 22 Sep 2025 15:38:36 +0200 Subject: [PATCH 4/4] Update index.ts --- packages/next/src/build/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index 373530c10cd5f..da9137728e814 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -2819,7 +2819,7 @@ export default async function build( ) const sortedStaticPaths = Array.from(staticPaths.entries()).sort( - ([a], [b]) => (a < b ? -1 : a > b ? 1 : 0) + ([a], [b]) => a.localeCompare(b) ) const exportApp = (require('../export') as typeof import('../export'))