Skip to content

Commit

Permalink
Update serial mode to be behind config
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Mar 24, 2021
1 parent eca84e6 commit c47e2ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
45 changes: 26 additions & 19 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,26 +511,33 @@ export default async function build(
const webpackBuildStart = process.hrtime()

let result: CompilerResult = { warnings: [], errors: [] }
// we run client and server compilation separately for memory and for
// serverless to be able to load manifests produced in previous build
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 when configured for
// memory constraint and for serverless to be able to load manifests
// produced in the client build
if (isLikeServerless || config.expeirmental.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],
}
}
}
})
})
} else {
result = await nextBuildSpan
.traceChild('run-webpack-compiler')
.traceAsyncFn(() => runCompiler(configs))
}

const webpackBuildEnd = process.hrtime(webpackBuildStart)
if (buildSpinner) {
Expand Down
1 change: 1 addition & 0 deletions packages/next/next-server/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const defaultConfig: NextConfig = {
scriptLoader: false,
stats: false,
externalDir: false,
serialWebpackBuild: false,
},
future: {
strictPostcssConfiguration: false,
Expand Down

0 comments on commit c47e2ae

Please sign in to comment.