webpack-visualizer icon indicating copy to clipboard operation
webpack-visualizer copied to clipboard

Huge discrepancy for minified size?

Open wmertens opened this issue 8 years ago • 4 comments

I was puzzled by the fact that my react-dom dependency is 506KB raw and 200KB minified, while the official build is 600KB raw and 120KB minified.

I tried comparing minification settings etc before thinking of simply creating an entry with only react-dom. That one has the minified react-dom at 109KB, much nicer and to be expected from tree shaking vs the full minified build.

So now I wonder, what causes the discrepancy between the minified size in my app.js vs the react-dom-only entry? Is there actually more code in the react-dom in my app.js? Are parts counted differently? All the minified sizes do seem to add up to the full minified size…

wmertens avatar Mar 14 '17 10:03 wmertens

Oh wow, I just found out that the minified size is just the proportion of the output bundle. In the case of React that is very inaccurate because a lot of code is snipped when compiling for production.

I was thinking that the minified sizes were a reasonable estimate, but that is not the case here.

So maybe the warning about the minified size should be changed to be "minified sizes are an estimation based solely on the raw size".

wmertens avatar Mar 14 '17 12:03 wmertens

+1 here. Tried to debug the same situation. React in app bundle size was 60kb, size of react in separate bundle was 20kb.

Made line by line comparison of each file in the minimised bundle. Result:

  1. There was indeed some additional files added by react-addons which added 14kb.
  2. But each of the common file was exactly the same size and length.

So full size must be 34kb, not 60kb. Same results as @wmertens for react-dom. Even worse for lodash.

iAdramelk avatar Apr 29 '17 17:04 iAdramelk

+1 My bundle visualization says react-dom is 2M actual / 512.1k raw I can't correlate that to what I see in node_modules/react-dom/dist: bwilkerson@IT-SEA14730-MBP:~/projects/zulily/htdocs_ems$ ls -lh app/v7/node_modules/react-dom/dist/ total 2904 -rw-r--r-- 1 bwilkerson CORP\Domain Users 560K Jun 14 17:00 react-dom-server.js -rw-r--r-- 1 bwilkerson CORP\Domain Users 123K Jun 14 17:00 react-dom-server.min.js -rw-r--r-- 1 bwilkerson CORP\Domain Users 638K Jun 14 17:00 react-dom.js -rw-r--r-- 1 bwilkerson CORP\Domain Users 127K Jun 14 17:00 react-dom.min.js

webpack_visualizer

littlebee avatar Jul 15 '17 00:07 littlebee

I think that this is same issue as https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/161

jskorepa avatar Apr 19 '18 21:04 jskorepa