rsnext/test/.stats-app/stats-config.js
Tobias Koppers 94ad03385b
remove commons chunk config (#34445)
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`
2022-02-19 22:26:54 +00:00

181 lines
4.4 KiB
JavaScript

const fs = require('fs')
const path = require('path')
// this page is conditionally added when not testing
// in webpack 4 mode since it's not supported for webpack 4
const imagePageData = fs.readFileSync(
path.join(__dirname, './image.js'),
'utf8'
)
const clientGlobs = [
{
name: 'Client Bundles (main, webpack)',
globs: [
'.next/static/runtime/+(main|webpack)-*',
'.next/static/chunks/!(polyfills*)',
],
},
{
name: 'Legacy Client Bundles (polyfills)',
globs: ['.next/static/chunks/+(polyfills)-*'],
},
{
name: 'Client Pages',
globs: ['.next/static/BUILD_ID/pages/**/*.js', '.next/static/css/**/*'],
},
{
name: 'Client Build Manifests',
globs: ['.next/static/BUILD_ID/_buildManifest*'],
},
{
name: 'Rendered Page Sizes',
globs: ['fetched-pages/**/*.html'],
},
]
const renames = [
{
srcGlob: '.next/static/chunks/pages',
dest: '.next/static/BUILD_ID/pages',
},
{
srcGlob: '.next/static/BUILD_ID/pages/**/*.js',
removeHash: true,
},
{
srcGlob: '.next/static/runtime/*.js',
removeHash: true,
},
{
srcGlob: '.next/static/chunks/*.js',
removeHash: true,
},
{
srcGlob: '.next/static/*/_buildManifest.js',
dest: '.next/static/BUILD_ID/_buildManifest.js',
},
]
module.exports = {
commentHeading: 'Stats from current PR',
commentReleaseHeading: 'Stats from current release',
appBuildCommand: 'NEXT_TELEMETRY_DISABLED=1 yarn next build',
appStartCommand: 'NEXT_TELEMETRY_DISABLED=1 yarn next start --port $PORT',
mainRepo: 'vercel/next.js',
mainBranch: 'canary',
autoMergeMain: true,
configs: [
{
title: 'Default Build',
diff: 'onOutputChange',
diffConfigFiles: [
{
path: 'pages/image.js',
content: imagePageData,
},
{
path: 'next.config.js',
content: `
module.exports = {
generateBuildId: () => 'BUILD_ID',
webpack(config) {
config.optimization.minimize = false
config.optimization.minimizer = undefined
return config
}
}
`,
},
],
// renames to apply to make file names deterministic
renames,
configFiles: [
{
path: 'pages/image.js',
content: imagePageData,
},
{
path: 'next.config.js',
content: `
module.exports = {
generateBuildId: () => 'BUILD_ID'
}
`,
},
],
filesToTrack: clientGlobs,
// will be output to fetched-pages/${pathname}.html
pagesToFetch: [
'http://localhost:$PORT/',
'http://localhost:$PORT/link',
'http://localhost:$PORT/withRouter',
],
pagesToBench: [
'http://localhost:$PORT/',
'http://localhost:$PORT/error-in-render',
],
benchOptions: {
reqTimeout: 60,
concurrency: 50,
numRequests: 2500,
},
},
{
title: 'Default Build with SWC',
diff: 'onOutputChange',
diffConfigFiles: [
{
path: 'pages/image.js',
content: imagePageData,
},
{
path: 'next.config.js',
content: `
module.exports = {
generateBuildId: () => 'BUILD_ID',
swcMinify: true,
webpack(config) {
config.optimization.minimize = false
config.optimization.minimizer = undefined
return config
}
}
`,
},
],
// renames to apply to make file names deterministic
renames,
configFiles: [
{
path: 'pages/image.js',
content: imagePageData,
},
{
path: 'next.config.js',
content: `
module.exports = {
swcMinify: true,
generateBuildId: () => 'BUILD_ID'
}
`,
},
],
filesToTrack: clientGlobs,
// will be output to fetched-pages/${pathname}.html
pagesToFetch: [
'http://localhost:$PORT/',
'http://localhost:$PORT/link',
'http://localhost:$PORT/withRouter',
],
pagesToBench: [
'http://localhost:$PORT/',
'http://localhost:$PORT/error-in-render',
],
benchOptions: {
reqTimeout: 60,
concurrency: 50,
numRequests: 2500,
},
},
],
}