Unverified Commit be33a9d8 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: Deterministic builds (prerender-manifest, .next/package.json,…

Turbopack: Deterministic builds (prerender-manifest, .next/package.json, ./next/postcss.js) (#84081)

### What?

* Make order of routes in prerender manifest deterministic
* Write the same package.json content to distDir
* fix output directory for postcss/webpack loaders entrypoint
parent 6779a5c0
...@@ -815,9 +815,9 @@ impl Project { ...@@ -815,9 +815,9 @@ impl Project {
let node_execution_chunking_context = Vc::upcast( let node_execution_chunking_context = Vc::upcast(
NodeJsChunkingContext::builder( NodeJsChunkingContext::builder(
self.project_root_path().owned().await?, self.project_root_path().owned().await?,
node_root.clone(), node_root.join("build")?,
self.node_root_to_root_path().owned().await?, self.node_root_to_root_path().owned().await?,
node_root.clone(), node_root.join("build")?,
node_root.join("build/chunks")?, node_root.join("build/chunks")?,
node_root.join("build/assets")?, node_root.join("build/assets")?,
node_build_environment().to_resolved().await?, node_build_environment().to_resolved().await?,
......
...@@ -2818,6 +2818,10 @@ export default async function build( ...@@ -2818,6 +2818,10 @@ export default async function build(
) )
) )
const sortedStaticPaths = Array.from(staticPaths.entries()).sort(
([a], [b]) => a.localeCompare(b)
)
const exportApp = (require('../export') as typeof import('../export')) const exportApp = (require('../export') as typeof import('../export'))
.default as typeof import('../export').default .default as typeof import('../export').default
...@@ -2885,7 +2889,7 @@ export default async function build( ...@@ -2885,7 +2889,7 @@ export default async function build(
// TODO: output manifest specific to app paths and their // TODO: output manifest specific to app paths and their
// revalidate periods and dynamicParams settings // revalidate periods and dynamicParams settings
staticPaths.forEach((routes, originalAppPath) => { sortedStaticPaths.forEach(([originalAppPath, routes]) => {
const appConfig = appDefaultConfigs.get(originalAppPath) const appConfig = appDefaultConfigs.get(originalAppPath)
const isDynamicError = appConfig?.dynamic === 'error' const isDynamicError = appConfig?.dynamic === 'error'
...@@ -3054,7 +3058,7 @@ export default async function build( ...@@ -3054,7 +3058,7 @@ export default async function build(
await fs.unlink(serverBundle) await fs.unlink(serverBundle)
} }
staticPaths.forEach((prerenderedRoutes, originalAppPath) => { sortedStaticPaths.forEach(([originalAppPath, prerenderedRoutes]) => {
const page = appNormalizedPaths.get(originalAppPath) const page = appNormalizedPaths.get(originalAppPath)
if (!page) throw new InvariantError('Page not found') if (!page) throw new InvariantError('Page not found')
......
...@@ -104,13 +104,7 @@ export async function turbopackBuild(): Promise<{ ...@@ -104,13 +104,7 @@ export async function turbopackBuild(): Promise<{
}) })
await fs.writeFile( await fs.writeFile(
path.join(distDir, 'package.json'), path.join(distDir, 'package.json'),
JSON.stringify( '{"type": "commonjs"}'
{
type: 'commonjs',
},
null,
2
)
) )
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
......
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