Skip to content

Commit

Permalink
remove commons chunk config (#34445)
Browse files Browse the repository at this point in the history
This removes the config for the `commons` chunk.

I think the idea was that modules are that in all pages are put into a `commons` chunk, but that breaks when next/dynamic comes into play, which also creates chunks. So the `totalPages` condition is broken and could lead to too many modules placed into the commons chunk.

Example: 2 pages, each has one next/dynamic. Both on demand chunks include module A. page 1 includes module B and next/dynamic on page 2 includes module B. A and B are placed into commons. commonjs chunk is loaded in page 1 and both next/dynamic. Page 1 would load module A even while it doesn't need it.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## 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.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
  • Loading branch information
sokra committed Feb 19, 2022
1 parent b701de6 commit 94ad033
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions packages/next/build/webpack-config.ts
Expand Up @@ -791,11 +791,6 @@ export default async function getBaseWebpackConfig(
minChunks: 1,
reuseExistingChunk: true,
},
commons: {
name: 'commons',
minChunks: totalPages,
priority: 20,
},
middleware: {
chunks: (chunk: webpack.compilation.Chunk) =>
chunk.name?.match(MIDDLEWARE_ROUTE),
Expand Down
2 changes: 1 addition & 1 deletion test/.stats-app/stats-config.js
Expand Up @@ -9,7 +9,7 @@ const imagePageData = fs.readFileSync(

const clientGlobs = [
{
name: 'Client Bundles (main, webpack, commons)',
name: 'Client Bundles (main, webpack)',
globs: [
'.next/static/runtime/+(main|webpack)-*',
'.next/static/chunks/!(polyfills*)',
Expand Down

0 comments on commit 94ad033

Please sign in to comment.