Skip to content

0.10 prerelease with webpack 2 increases bundle size #1843

Closed

Description

@gavinwahl

On a newly created empty project and react-scripts@0.9.5, I get these bundle sizes for the production build after running yarn run build:

  46.12 KB  build/static/js/main.fcaea709.js
  289 B     build/static/css/main.9a0fe4f1.css

After upgrading to the 0.10.0 alpha (328cb32), I get:

  46.28 KB (+163 B)  build/static/js/main.f27b292b.js
  317 B (+28 B)      build/static/css/main.1f6b6bee.css

I expect the bundle size not to increase after upgrading. In my production project, I get an even larger increase:

  268.18 KB (+2.22 KB)  build/static/js/main.1d20828f.js
  32.15 KB (+4.9 KB)    build/static/css/main.0d46d1be.css

Activity

  1. Timer commented on Mar 17, 2017

    @Timer
    Contributor

    Part of the reason is because of webpack/webpack#4493. I'm not sure why the existing build is growing so much ... probably the same reason (I'd hope).

    Can you look at this with source-map-explorer as explained in #1641?

    Unfortunately we cannot leverage tree-shaking yet (and are using babel to compile to commonjs) because sourcemaps are broken (webpack/webpack#4423), and tree-shaking actually doesn't work at all (webpack/webpack#2867, webpack/webpack#2899, webpack/webpack#3092).

  2. added this to the milestone on Mar 17, 2017
  3. gavinwahl commented on Mar 17, 2017

    @gavinwahl
    Author

    0.9.5:
    0.9.5

    0.10.0:
    0.10.0

    Now I'm confused...source-ma-explorer is reporting the 0.10.0 as smaller...maybe it got less compressible?

  4. Timer commented on Mar 17, 2017

    @Timer
    Contributor

    Interesting... I wonder if webpack 1 vs 2 have different versions of uglify and there was a regression on that front...

    Unless if we regressed in our configuration.

  5. Timer commented on Mar 17, 2017

    @Timer
    Contributor

    Maybe the default configuration changed, can you try some of the options in #1644? You can edit the config file in your node_modules.

  6. gaearon commented on Mar 17, 2017

    @gaearon
    Contributor

    I'd be surprised if it was Uglify. I suspect some polyfill we happen to bundle (e.g. process) got larger, something changed at module boundaries, or some pattern got harder to uglify (e.g. something that used to repeat in Webpack 1 is now unique every time defeating compression in Webpack 2).

    Need to look at minimal bundles from both. Also at minimal bundles without React for both.

  7. AJamesPhillips commented on Mar 21, 2017

    @AJamesPhillips
    Contributor

    I don't know if it's useful but I marked up a few of the differences on 0.10.0. lodash appears to be included twice (two large purple boxes), I'm not certain what's going on there. Generally all parts in 0.10.0 are smaller by up to a couple of kb but there were some exceptions (significant decrease (green), no change (blue), increase(red)) and some name changes from lib to es or Nnn to Nnn-es (purple smaller boxes).

    wb2

  8. watert commented on Apr 11, 2017

    @watert

    @AJamesPhillips how is this log printed? seems great.

  9. AJamesPhillips commented on Apr 11, 2017

    @AJamesPhillips
    Contributor

    @watert I just took the screen shots from gavinwahl's posts above. He might have followed the instructions Timer link to in his comment.

  10. modified the milestones: , on May 14, 2017
  11. modified the milestones: 1.0.1, 1.0.x on May 19, 2017
  12. Timer commented on Aug 2, 2017

    @Timer
    Contributor

    Closing this as unactionable by us; webpack updated its node stubs which are now larger -- we've actually removed some of these stubs by default now so your bundle might have shrunk.

    Feel free to open a new issue if someone has something compelling.

  13. locked and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions