bundle-stats: Sort duplicate modules by duplicate size
It would be nice to be able to sort the list of duplicate modules by:
- Number of duplicates (i.e. number of chunks that contain it)
- Duplicates size (
duplicateSize = moduleSize*(nChunks - 1))
The second is a way to see the modules doing the most damage to bundle size via duplicates.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 2
- Comments: 19 (14 by maintainers)
Here’s a PR result that I think is a good large case study for this:
https://github.com/home-assistant/frontend/pull/16506/checks?check_run_id=19990121982
Basically, all this PR does is adjust Babel settings for reduced transpilation and polyfills, so the vast majority of modules see a decrease in size. However, the bundle size went up by 2.6%, seemingly because of increased duplication. RelativeCI is not much help in narrowing down there the increases are coming from. The goal should be to make that clear with little effort.
@steverep thank you for the feedback, i think they are all very useful additions. I created new tickets for 1-2 and added them along with #4296 to the todo list 😉
@danielbeardsley changes were merged and released as
4.12.0-beta.0.I certainly agree that byte size is the more useful measure, but I disagree that looking at quantity of duplicates has no use. In our bundle I’ve found modules repeated 30-50 times. Sometimes they are very small, but that still clearly points to optimizations that can be made. Sorting by number of duplicates should also be an option.
for reference, we are considering to pick up the production-correlated size using the results from webpack-bundle-analyzer or by using another method 😉