Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle with browser-pack-flat plugin #2447

Merged
merged 2 commits into from
Mar 7, 2018

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Mar 6, 2018

A nice benefit from removing all circular deps in #2429, browser-pack-flat now allows us to trim some bundle bits (especially in our minified bundle).

Here's what browser-pack-flat can trim:

image

that's about 10 gzip+minified kB per bundle. Not bad I think.

That said, using browser-pack-flat comes at a price 馃挵 , npm run build is not a bit slower and consumes a lot more memory. So I had to use run-series to reduce memory consumption and make npm run build succeed consistently. Note also, I thinking of only using browser-pack-flat during npm run build to not slow npm run watch and npm start.


Referencing https://github.com/plotly/plotly-webpack/issues/2 that first discussed bundling with browser-pack-flat.

... that can lead to `npm run build` blowing up (especially with
    browser-pack-flat - see next commit).

- adapt opts.then to callback signatrue instead
- make opts more granular and clearer
@alexcjohnson
Copy link
Collaborator

Seems like a clear win, and all the choices you made seem right. One question though: why did the raw sizes increase?

@etpinard
Copy link
Contributor Author

etpinard commented Mar 7, 2018

One question though: why did the raw sizes increase?

Good question. I think it has to do with the long variable names browser-pack-flat uses to denote exported fields in the global scope (example here) brower-pack-flat seems to be more liberal on \n too. Uglifyjs can easily 馃敧 those things hence to smaller minified bundles.

@alexcjohnson
Copy link
Collaborator

Also:

browser-pack-flat does some more things like rewriting top-level variables in modules in case there is another variable with the same name in another module

Those names probably start getting pretty long in our bundle.

Anyway anyone who cares about size will use the minified versions, and this is a clear win. 馃拑

@etpinard etpinard merged commit dfe13b5 into plotly:master Mar 7, 2018
@etpinard etpinard deleted the browser-pack-flat branch March 7, 2018 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants