Open mindrones opened 5 years ago
I tried some rollup plugins to output the bundle sizes:
1) rollup-plugin-size-snapshot
: the current release doesn't as it expects output
being a string, while we pass the object returned by config.client.output()
:
{
"dir": "path/to/__sapper__/dev/client",
"entryFileNames": "[name].[hash].js",
"chunkFileNames": "[name].[hash].js",
"format": "esm",
"sourcemap": false
}
patching this with:
-const output = outputOptions.file;
+const output = outputOptions.file || outputOptions.dir;
we get [1] but notice that it's very slow (it takes many seconds at least here):
2) rollup-plugin-sizes
: works, outputs this kind of info [1] and could be used to track down the bigger dependency to investigate first.
We get:
We can check if dependencies have "sideEffects": false
in package.json
, with a script eventually.
It is unlikely that this will help much as not many packages will have that variable, but hopefully the bigger ones will (lamb
has it for example).
This plugin is the best I've found so far: https://github.com/doesdev/rollup-plugin-analyzer 👍, see https://github.com/nestauk/svizzle/commit/b1e377bebcd8a07d8e526c3a4c1838615e0665de
There's a list of d3 modules sideEffects
at https://github.com/d3/d3/issues/3131#issuecomment-517316673
(formatting the link as text as I'd rather not link this comment there).
We're now using the new rollup's option
treeshake.moduleSideEffects
for lamb (see [1]), we should investigate how to detect purity in other dependencies, especially the big ones like xstate.There is and will be work on auto-detect side-effects in rollup [2] but while we wait for that to be solved completely we need a way to at least list pure modules if we feel it's the case and if the lib is not too difficult to inspect.
[1] https://github.com/mindrones/lambsplittest/commit/db02018ff8e4034788af45bf7bd63c907de2e602#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R19
[2] rollup PR 2844: