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 = { ...@@ -58,7 +58,7 @@ export type WebpackEntrypoints = {
| string[] | string[]
| { | {
import: string | string[] import: string | string[]
dependOn: string | string[] dependOn?: string | string[]
} }
} }
......
This diff is collapsed.
...@@ -822,7 +822,17 @@ export default async function getBaseWebpackConfig( ...@@ -822,7 +822,17 @@ export default async function getBaseWebpackConfig(
...(isWebpack5 ? { emitOnErrors: !dev } : { noEmitOnErrors: dev }), ...(isWebpack5 ? { emitOnErrors: !dev } : { noEmitOnErrors: dev }),
checkWasmTypes: false, checkWasmTypes: false,
nodeEnv: 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 runtimeChunk: isServer
? isWebpack5 && !isLikeServerless ? isWebpack5 && !isLikeServerless
? { name: 'webpack-runtime' } ? { name: 'webpack-runtime' }
......
...@@ -38,7 +38,7 @@ export default class PagesManifestPlugin implements webpack.Plugin { ...@@ -38,7 +38,7 @@ export default class PagesManifestPlugin implements webpack.Plugin {
!file.includes('webpack-runtime') && file.endsWith('.js') !file.includes('webpack-runtime') && file.endsWith('.js')
) )
if (files.length > 1) { if (!isWebpack5 && files.length > 1) {
console.log( console.log(
`Found more than one file in server entrypoint ${entrypoint.name}`, `Found more than one file in server entrypoint ${entrypoint.name}`,
files files
...@@ -47,7 +47,7 @@ export default class PagesManifestPlugin implements webpack.Plugin { ...@@ -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. // 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) { if (isWebpack5 && !this.dev) {
pages[pagePath] = pages[pagePath].slice(3) pages[pagePath] = pages[pagePath].slice(3)
......
...@@ -48,7 +48,7 @@ initNext({ webpackHMR }) ...@@ -48,7 +48,7 @@ initNext({ webpackHMR })
const { pages } = JSON.parse(event.data) const { pages } = JSON.parse(event.data)
const router = window.next.router 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') console.log('Refreshing page data due to server-side change')
buildIndicatorHandler('building') 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