Closed jelly closed 1 week ago
We could, only import the locales which are required.
By doing the following changes in the build.js one can generate a meta.json file
[kkoukiou@sequioa cockpit]$ git diff
diff --git build.js build.js
index d20324070..60059d8ed 100755
--- build.js
+++ build.js
@@ -225,6 +225,7 @@ async function build() {
} else {
// with native esbuild, build everything in one go, that's fastest
const pkgContext = await esbuild.context({
+ metafile: true,
...pkgOptions,
entryPoints,
plugins: [...pkgFirstPlugins, ...pkgPlugins, ...pkgLastPlugins],
@@ -241,7 +242,8 @@ async function build() {
});
try {
- await Promise.all([pkgContext.rebuild(), qunitContext.rebuild()]);
+ const result = await Promise.all([pkgContext.rebuild(), qunitContext.rebuild()]);
+ fs.writeFileSync('meta.json', JSON.stringify(result[0].metafile));
} catch (e) {
if (!args.watch)
process.exit(1);
Which can be then fed to https://esbuild.github.io/analyze/
@KKoukiou: Nice! Do you want to add that as a CLI option to ./build.js? Or is this cheap enough that we could just always do that?
@martinpitt I definitely want to introduce it as a CLI option and I want to introduce some check for bundle size changes, so if bundle size increases by >5% there should be an error in CI.
In our cockpit plugins we now generate an esbuild metadata file which can be used to analyze the bundle size https://github.com/cockpit-project/starter-kit/commit/49c368809e7667f066f13605286178b4ab75b78f
Add the webpack bundle analyzer to package.json and the webpack config and run
./tools/webpack-make $page
.Biggest modules:
systemd/services.js (3.6 MB)
kdump (1.69 MB)
users 3.3MB
storaged 3.8 MB
Note: the bundle does include
test-util.js
. for storaged/kdump