Unverified Commit 3bf4ae37 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

performance improvement of static generation (#25035)

### move all access to built pages into worker pool

to allow parallelizing and avoid loading the bundles in the main thread

This improves performance of the static check step a bit and helps reducing memory load in main thread

### enable splitChunks for server build in webpack 5

This improves performance for static generation by loading less code due to reduced duplication
parent a4420532
......@@ -58,7 +58,7 @@ export type WebpackEntrypoints = {
| string[]
| {
import: string | string[]
dependOn: string | string[]
dependOn?: string | string[]
}
}
......
This diff is collapsed.
......@@ -822,7 +822,17 @@ export default async function getBaseWebpackConfig(
...(isWebpack5 ? { emitOnErrors: !dev } : { noEmitOnErrors: dev }),
checkWasmTypes: false,
nodeEnv: false,
splitChunks: isServer ? false : splitChunksConfig,
splitChunks: isServer
? isWebpack5
? {
// allow to split entrypoints
chunks: 'all',
// size of files is not so relevant for server build
// we want to prefer deduplication to load less code
minSize: 1000,
}
: false
: splitChunksConfig,
runtimeChunk: isServer
? isWebpack5 && !isLikeServerless
? { name: 'webpack-runtime' }
......
......@@ -38,7 +38,7 @@ export default class PagesManifestPlugin implements webpack.Plugin {
!file.includes('webpack-runtime') && file.endsWith('.js')
)
if (files.length > 1) {
if (!isWebpack5 && files.length > 1) {
console.log(
`Found more than one file in server entrypoint ${entrypoint.name}`,
files
......@@ -47,7 +47,7 @@ export default class PagesManifestPlugin implements webpack.Plugin {
}
// Write filename, replace any backslashes in path (on windows) with forwardslashes for cross-platform consistency.
pages[pagePath] = files[0]
pages[pagePath] = files[files.length - 1]
if (isWebpack5 && !this.dev) {
pages[pagePath] = pages[pagePath].slice(3)
......
......@@ -48,7 +48,7 @@ initNext({ webpackHMR })
const { pages } = JSON.parse(event.data)
const router = window.next.router
if (pages.includes(router.pathname)) {
if (!router.clc && pages.includes(router.pathname)) {
console.log('Refreshing page data due to server-side change')
buildIndicatorHandler('building')
......
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