未验证 提交 a6c0d76e 编写于 作者: J JJ Kasper 提交者: GitHub

Run server client/server builds serially (#23371)



Previously we special cased serverless builds and ran the client/server builds serially to allow the server build to load manifests produced in the client. To help with memory usage and for consistency this updates server mode to build in the same way.  

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
上级 98211405
...@@ -511,22 +511,28 @@ export default async function build( ...@@ -511,22 +511,28 @@ export default async function build(
const webpackBuildStart = process.hrtime() const webpackBuildStart = process.hrtime()
let result: CompilerResult = { warnings: [], errors: [] } let result: CompilerResult = { warnings: [], errors: [] }
// TODO: why do we need this?? https://github.com/vercel/next.js/issues/8253 // We run client and server compilation separately when configured for
if (isLikeServerless) { // memory constraint and for serverless to be able to load manifests
const clientResult = await runCompiler(clientConfig) // produced in the client build
// Fail build if clientResult contains errors if (isLikeServerless || config.experimental.serialWebpackBuild) {
if (clientResult.errors.length > 0) { await nextBuildSpan
result = { .traceChild('run-webpack-compiler')
warnings: [...clientResult.warnings], .traceAsyncFn(async () => {
errors: [...clientResult.errors], const clientResult = await runCompiler(clientConfig)
} // Fail build if clientResult contains errors
} else { if (clientResult.errors.length > 0) {
const serverResult = await runCompiler(configs[1]) result = {
result = { warnings: [...clientResult.warnings],
warnings: [...clientResult.warnings, ...serverResult.warnings], errors: [...clientResult.errors],
errors: [...clientResult.errors, ...serverResult.errors], }
} } else {
} const serverResult = await runCompiler(configs[1])
result = {
warnings: [...clientResult.warnings, ...serverResult.warnings],
errors: [...clientResult.errors, ...serverResult.errors],
}
}
})
} else { } else {
result = await nextBuildSpan result = await nextBuildSpan
.traceChild('run-webpack-compiler') .traceChild('run-webpack-compiler')
......
...@@ -80,6 +80,7 @@ export const defaultConfig: NextConfig = { ...@@ -80,6 +80,7 @@ export const defaultConfig: NextConfig = {
scriptLoader: false, scriptLoader: false,
stats: false, stats: false,
externalDir: false, externalDir: false,
serialWebpackBuild: false,
}, },
future: { future: {
strictPostcssConfiguration: false, strictPostcssConfiguration: false,
......
...@@ -4730,7 +4730,7 @@ caniuse-api@^3.0.0: ...@@ -4730,7 +4730,7 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2" lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0" lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001173, caniuse-lite@^1.0.30001179: caniuse-lite@1.0.30001179, caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001173, caniuse-lite@^1.0.30001179:
version "1.0.30001179" version "1.0.30001179"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001179.tgz#b0803883b4471a6c62066fb1752756f8afc699c8" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001179.tgz#b0803883b4471a6c62066fb1752756f8afc699c8"
integrity sha512-blMmO0QQujuUWZKyVrD1msR4WNDAqb/UPO1Sw2WWsQ7deoM5bJiicKnWJ1Y0NS/aGINSnKPIWBMw5luX+NDUCA== integrity sha512-blMmO0QQujuUWZKyVrD1msR4WNDAqb/UPO1Sw2WWsQ7deoM5bJiicKnWJ1Y0NS/aGINSnKPIWBMw5luX+NDUCA==
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册