Skip to content

Commit

Permalink
Enable serial build by default (#25642)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored Jun 2, 2021
1 parent 9c3780f commit 5a5f0d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
44 changes: 18 additions & 26 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,33 +543,25 @@ export default async function build(
const webpackBuildStart = process.hrtime()

let result: CompilerResult = { warnings: [], errors: [] }
// We run client and server compilation separately when configured for
// memory constraint and for serverless to be able to load manifests
// produced in the client build
if (isLikeServerless || config.experimental.serialWebpackBuild) {
await nextBuildSpan
.traceChild('run-webpack-compiler')
.traceAsyncFn(async () => {
const clientResult = await runCompiler(clientConfig)
// Fail build if clientResult contains errors
if (clientResult.errors.length > 0) {
result = {
warnings: [...clientResult.warnings],
errors: [...clientResult.errors],
}
} else {
const serverResult = await runCompiler(configs[1])
result = {
warnings: [...clientResult.warnings, ...serverResult.warnings],
errors: [...clientResult.errors, ...serverResult.errors],
}
// We run client and server compilation separately to optimize for memory usage
await nextBuildSpan
.traceChild('run-webpack-compiler')
.traceAsyncFn(async () => {
const clientResult = await runCompiler(clientConfig)
// Fail build if clientResult contains errors
if (clientResult.errors.length > 0) {
result = {
warnings: [...clientResult.warnings],
errors: [...clientResult.errors],
}
})
} else {
result = await nextBuildSpan
.traceChild('run-webpack-compiler')
.traceAsyncFn(() => runCompiler(configs))
}
} else {
const serverResult = await runCompiler(configs[1])
result = {
warnings: [...clientResult.warnings, ...serverResult.warnings],
errors: [...clientResult.errors, ...serverResult.errors],
}
}
})

const webpackBuildEnd = process.hrtime(webpackBuildStart)
if (buildSpinner) {
Expand Down
2 changes: 0 additions & 2 deletions packages/next/next-server/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export type NextConfig = { [key: string]: any } & {
scriptLoader?: boolean
stats?: boolean
externalDir?: boolean
serialWebpackBuild?: boolean
conformance?: boolean
amp?: {
optimizer?: any
Expand Down Expand Up @@ -115,7 +114,6 @@ export const defaultConfig: NextConfig = {
scriptLoader: false,
stats: false,
externalDir: false,
serialWebpackBuild: false,
turboMode: false,
eslint: false,
reactRoot: Number(process.env.NEXT_PRIVATE_REACT_ROOT) > 0,
Expand Down

0 comments on commit 5a5f0d0

Please sign in to comment.