Skip to content

Commit

Permalink
Update webpack output names
Browse files Browse the repository at this point in the history
Context: in webpack v5, the files associated with the "core-vendors"
custom group are classified as initial (entry-point) chunk files [1]
when that was not the case in webpack v4. Not sure why.

Add [name] to filename to be more consistent with chunkFilename, and so
it's easier to understand the association between files and cacheGroups.

Update the bundlesize config glob patterns to match these new names.
Since the exact reason for filename vs. chunkFilename isn't clear to me,
I updated all glob patterns to match either.

Before:

    % ls -1 dist/*.js
    dist/auspice.bundle.9317bbd7a88738acbd84.js
    dist/auspice.bundle.a643293e8d8d26eb8631.js
    dist/auspice.chunk.106.bundle.db610e43983c64187457.js
    dist/auspice.chunk.145.bundle.4e68f1faa6878e1ced83.js
    dist/auspice.chunk.236.bundle.aafe143fec2bd894590f.js
    dist/auspice.chunk.383.bundle.79ae23992e50e870b00b.js
    dist/auspice.chunk.452.bundle.b75a285a5a08ef86511b.js
    dist/auspice.chunk.550.bundle.7a8bceea70ffde7edbf6.js
    dist/auspice.chunk.601.bundle.9a996464f910afbe8d17.js
    dist/auspice.chunk.718.bundle.8a109e6ba40b88251b95.js
    dist/auspice.chunk.815.bundle.2020e527c8ed3ebe83c5.js
    dist/auspice.chunk.971.bundle.a4099131fc6b718b0b0e.js
    dist/auspice.chunk.978.bundle.a3c6f896f16908bb753d.js
    dist/auspice.chunk.locales.bundle.49f1377f1c9b33ffa9c3.js
    dist/auspice.chunk.other-vendors.bundle.c38604b639c95e112558.js

After:

    % ls -1 dist/*.js
    dist/auspice.chunk.106.bundle.db610e43983c64187457.js
    dist/auspice.chunk.145.bundle.4e68f1faa6878e1ced83.js
    dist/auspice.chunk.236.bundle.aafe143fec2bd894590f.js
    dist/auspice.chunk.383.bundle.79ae23992e50e870b00b.js
    dist/auspice.chunk.452.bundle.b75a285a5a08ef86511b.js
    dist/auspice.chunk.550.bundle.7a8bceea70ffde7edbf6.js
    dist/auspice.chunk.601.bundle.9a996464f910afbe8d17.js
    dist/auspice.chunk.718.bundle.8a109e6ba40b88251b95.js
    dist/auspice.chunk.815.bundle.2020e527c8ed3ebe83c5.js
    dist/auspice.chunk.971.bundle.a4099131fc6b718b0b0e.js
    dist/auspice.chunk.978.bundle.a3c6f896f16908bb753d.js
    dist/auspice.chunk.locales.bundle.49f1377f1c9b33ffa9c3.js
    dist/auspice.chunk.other-vendors.bundle.c38604b639c95e112558.js
    dist/auspice.core-vendors.bundle.209f45d95b5b37faa31c.js
    dist/auspice.main.bundle.9317bbd7a88738acbd84.js

[1]: https://webpack.js.org/configuration/output/#outputchunkfilename
  • Loading branch information
victorlin committed Oct 10, 2022
1 parent a4124da commit 8b82594
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"files": [
{
"path": "./dist/auspice.bundle.*.js",
"path": "./dist/auspice.main.bundle.*.js",
"maxSize": "2 kB"
},
{
"path": "./dist/auspice.chunk.+([0-9]).bundle.*.js",
"path": "./dist/auspice.?(chunk.)+([0-9]).bundle.*.js",
"maxSize": "100 kB"
},
{
"path": "./dist/auspice.chunk.core-vendors.bundle.*.js",
"path": "./dist/auspice.?(chunk.)core-vendors.bundle.*.js",
"maxSize": "220 kB"
},
{
"path": "./dist/auspice.chunk.other-vendors.bundle.*.js",
"path": "./dist/auspice.?(chunk.)other-vendors.bundle.*.js",
"maxSize": "150 kB"
},
{
"path": "./dist/auspice.chunk.locales.bundle.*.js",
"path": "./dist/auspice.?(chunk.)locales.bundle.*.js",
"maxSize": "100 kB"
}
]
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
entry,
output: {
path: outputPath,
filename: `auspice.bundle${!devMode ? ".[contenthash]" : ""}.js`,
filename: `auspice.[name].bundle${!devMode ? ".[contenthash]" : ""}.js`,
chunkFilename: `auspice.chunk.[name].bundle${!devMode ? ".[chunkhash]" : ""}.js`,
publicPath: "/dist/"
},
Expand Down

0 comments on commit 8b82594

Please sign in to comment.