2024-04-26 19:57:22 +02:00
|
|
|
const fs = require('fs/promises')
|
|
|
|
const path = require('path')
|
|
|
|
|
2019-08-12 00:28:41 +02:00
|
|
|
const clientGlobs = [
|
|
|
|
{
|
2022-02-19 23:26:54 +01:00
|
|
|
name: 'Client Bundles (main, webpack)',
|
2019-08-12 00:28:41 +02:00
|
|
|
globs: [
|
2020-11-18 19:30:00 +01:00
|
|
|
'.next/static/runtime/+(main|webpack)-*',
|
|
|
|
'.next/static/chunks/!(polyfills*)',
|
2019-11-11 04:24:53 +01:00
|
|
|
],
|
2019-08-12 00:28:41 +02:00
|
|
|
},
|
2019-11-05 22:15:42 +01:00
|
|
|
{
|
|
|
|
name: 'Legacy Client Bundles (polyfills)',
|
2020-11-18 19:30:00 +01:00
|
|
|
globs: ['.next/static/chunks/+(polyfills)-*'],
|
2019-11-05 22:15:42 +01:00
|
|
|
},
|
2019-08-12 00:28:41 +02:00
|
|
|
{
|
|
|
|
name: 'Client Pages',
|
2024-02-13 23:40:19 +01:00
|
|
|
globs: [
|
|
|
|
'.next/static/BUILD_ID/pages/!(edge-repeated*)',
|
|
|
|
'.next/static/css/**/*',
|
|
|
|
],
|
2019-08-20 08:28:09 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Client Build Manifests',
|
2021-07-07 16:50:24 +02:00
|
|
|
globs: ['.next/static/BUILD_ID/_buildManifest*'],
|
2019-08-24 01:36:44 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Rendered Page Sizes',
|
2024-02-13 23:40:19 +01:00
|
|
|
globs: ['fetched-pages/!(edge-repeated*)'],
|
2019-11-11 04:24:53 +01:00
|
|
|
},
|
2022-08-15 20:28:31 +02:00
|
|
|
{
|
2022-09-22 02:18:18 +02:00
|
|
|
name: 'Edge SSR bundle Size',
|
|
|
|
globs: [
|
|
|
|
'.next/server/pages/edge-ssr.js',
|
|
|
|
'.next/server/app/app-edge-ssr/page.js',
|
|
|
|
],
|
2024-04-26 19:57:22 +02:00
|
|
|
getRequiredFiles: async (nextAppDir, fileName) => {
|
|
|
|
if (fileName.startsWith('.next/server/app')) {
|
|
|
|
const manifestJson = await fs.readFile(
|
|
|
|
path.join(nextAppDir, '.next/server/middleware-manifest.json')
|
|
|
|
)
|
|
|
|
const manifest = JSON.parse(manifestJson)
|
|
|
|
const manifestFileEntry = path.relative(
|
|
|
|
path.join(nextAppDir, '.next'),
|
|
|
|
path.join(nextAppDir, fileName)
|
|
|
|
)
|
|
|
|
|
|
|
|
const functionEntry = Object.values(manifest.functions).find(
|
|
|
|
(entry) => {
|
|
|
|
return entry.files.includes(manifestFileEntry)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
if (functionEntry === undefined) {
|
|
|
|
throw new Error(
|
|
|
|
`${manifestFileEntry} is not listed in the files files of any functions in the manifest:\n` +
|
|
|
|
JSON.stringify(manifest, null, 2)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return functionEntry.files.map((file) => {
|
|
|
|
return path.join('.next', file)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
return [fileName]
|
|
|
|
}
|
|
|
|
},
|
2022-08-15 20:28:31 +02:00
|
|
|
},
|
2022-06-07 19:05:48 +02:00
|
|
|
{
|
|
|
|
name: 'Middleware size',
|
2022-07-06 20:17:57 +02:00
|
|
|
globs: [
|
|
|
|
'.next/server/middleware*.js',
|
|
|
|
'.next/server/edge-runtime-webpack.js',
|
|
|
|
],
|
2022-06-07 19:05:48 +02:00
|
|
|
},
|
2023-10-12 10:27:44 +02:00
|
|
|
{
|
|
|
|
name: 'Next Runtimes',
|
2023-11-04 00:39:37 +01:00
|
|
|
globs: ['node_modules/next/dist/compiled/next-server/**/*.js'],
|
2023-10-12 10:27:44 +02:00
|
|
|
},
|
2024-02-13 23:40:19 +01:00
|
|
|
{
|
|
|
|
name: 'build cache',
|
|
|
|
globs: ['.next/cache/**/*'],
|
|
|
|
},
|
2019-08-12 00:28:41 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
const renames = [
|
|
|
|
{
|
2021-07-07 16:50:24 +02:00
|
|
|
srcGlob: '.next/static/chunks/pages',
|
2019-11-11 04:24:53 +01:00
|
|
|
dest: '.next/static/BUILD_ID/pages',
|
2019-08-12 00:28:41 +02:00
|
|
|
},
|
|
|
|
{
|
2021-07-07 16:50:24 +02:00
|
|
|
srcGlob: '.next/static/BUILD_ID/pages/**/*.js',
|
2021-04-15 13:46:56 +02:00
|
|
|
removeHash: true,
|
2019-08-12 00:28:41 +02:00
|
|
|
},
|
2021-01-19 20:15:45 +01:00
|
|
|
{
|
2021-07-07 16:50:24 +02:00
|
|
|
srcGlob: '.next/static/runtime/*.js',
|
2021-04-15 13:46:56 +02:00
|
|
|
removeHash: true,
|
2021-01-19 20:15:45 +01:00
|
|
|
},
|
2019-08-12 00:28:41 +02:00
|
|
|
{
|
2021-07-07 16:50:24 +02:00
|
|
|
srcGlob: '.next/static/chunks/*.js',
|
2021-04-15 13:46:56 +02:00
|
|
|
removeHash: true,
|
2019-08-12 00:28:41 +02:00
|
|
|
},
|
2019-08-20 08:28:09 +02:00
|
|
|
{
|
|
|
|
srcGlob: '.next/static/*/_buildManifest.js',
|
2019-11-11 04:24:53 +01:00
|
|
|
dest: '.next/static/BUILD_ID/_buildManifest.js',
|
2019-08-20 08:28:09 +02:00
|
|
|
},
|
2019-08-12 00:28:41 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
commentHeading: 'Stats from current PR',
|
|
|
|
commentReleaseHeading: 'Stats from current release',
|
2023-08-04 21:40:20 +02:00
|
|
|
appBuildCommand: 'NEXT_TELEMETRY_DISABLED=1 pnpm next build',
|
|
|
|
appStartCommand: 'NEXT_TELEMETRY_DISABLED=1 pnpm next start --port $PORT',
|
|
|
|
appDevCommand: 'NEXT_TELEMETRY_DISABLED=1 pnpm next --port $PORT',
|
2020-05-27 23:51:11 +02:00
|
|
|
mainRepo: 'vercel/next.js',
|
2019-08-12 00:28:41 +02:00
|
|
|
mainBranch: 'canary',
|
|
|
|
autoMergeMain: true,
|
|
|
|
configs: [
|
|
|
|
{
|
2021-06-30 11:41:55 +02:00
|
|
|
title: 'Default Build',
|
2019-08-12 00:28:41 +02:00
|
|
|
diff: 'onOutputChange',
|
|
|
|
diffConfigFiles: [
|
|
|
|
{
|
|
|
|
path: 'next.config.js',
|
|
|
|
content: `
|
|
|
|
module.exports = {
|
2019-09-09 23:06:13 +02:00
|
|
|
generateBuildId: () => 'BUILD_ID',
|
2019-08-12 00:28:41 +02:00
|
|
|
webpack(config) {
|
|
|
|
config.optimization.minimize = false
|
|
|
|
config.optimization.minimizer = undefined
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
}
|
2019-11-11 04:24:53 +01:00
|
|
|
`,
|
|
|
|
},
|
2019-08-12 00:28:41 +02:00
|
|
|
],
|
|
|
|
// renames to apply to make file names deterministic
|
|
|
|
renames,
|
|
|
|
configFiles: [
|
|
|
|
{
|
|
|
|
path: 'next.config.js',
|
|
|
|
content: `
|
2022-09-22 02:18:18 +02:00
|
|
|
module.exports = {
|
2020-11-18 19:30:00 +01:00
|
|
|
generateBuildId: () => 'BUILD_ID'
|
2019-08-12 00:28:41 +02:00
|
|
|
}
|
2019-11-11 04:24:53 +01:00
|
|
|
`,
|
|
|
|
},
|
2019-08-12 00:28:41 +02:00
|
|
|
],
|
|
|
|
filesToTrack: clientGlobs,
|
2019-08-24 01:36:44 +02:00
|
|
|
// will be output to fetched-pages/${pathname}.html
|
2019-08-12 00:28:41 +02:00
|
|
|
pagesToFetch: [
|
2019-08-24 01:36:44 +02:00
|
|
|
'http://localhost:$PORT/',
|
2019-08-12 20:53:11 +02:00
|
|
|
'http://localhost:$PORT/link',
|
2019-11-11 04:24:53 +01:00
|
|
|
'http://localhost:$PORT/withRouter',
|
|
|
|
],
|
2022-10-15 03:17:45 +02:00
|
|
|
// TODO: investigate replacing "ab" for this
|
|
|
|
// pagesToBench: [
|
|
|
|
// 'http://localhost:$PORT/',
|
|
|
|
// 'http://localhost:$PORT/error-in-render',
|
|
|
|
// ],
|
|
|
|
// benchOptions: {
|
|
|
|
// reqTimeout: 60,
|
|
|
|
// concurrency: 50,
|
|
|
|
// numRequests: 2500,
|
|
|
|
// },
|
2019-08-12 00:28:41 +02:00
|
|
|
},
|
2019-11-11 04:24:53 +01:00
|
|
|
],
|
2019-08-12 00:28:41 +02:00
|
|
|
}
|