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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Code-split bundled WMR for performance #62

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

developit
Copy link
Member

@developit developit commented Jul 13, 2020

Currently we generate a single 1.5mb wmr.cjs file. This is really nice for distribution, but it does mean that anyone running wmr pays the full cost of parsing and compiling all that JS, even though roughly half of it is used depending on whether you're running wmr or wmr build.

I've tested out a few configurations, and this is what I came up with: basically it generates a couple more files (3 or 4) so that "prod bundling" and "http2" are handled in 1.1mb and 160kb commonjs modules that are conditionally loaded the first time they are used. In the case of running wmr (watch mode), neither are loaded.

I'm on the fence about whether this is the right thing to do. From a performance standpoint it will probably be a faster startup, but it complicates delivery (in a way that maybe only I care about? lol) 📦

@developit developit added the DRAFT Draft, not ready for merging label Jul 13, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jul 13, 2020

Size Change: -289 kB (43%) 🎉

Total Size: 660 kB

Filename Size Change
wmr.cjs 376 kB -289 kB (76%) 🏆
ℹ️ View Unchanged
Filename Size Change
demo/dist/assets/style.********.css 266 B 0 B
demo/dist/assets/style.module.********.css 53 B 0 B
demo/dist/chunks/index.********.js 294 B 0 B
demo/dist/index.********.js 5.95 kB 0 B
demo/dist/index.html 403 B 0 B
wmr.bundler.cjs 194 kB 0 B
wmr.http2.cjs 57.5 kB 0 B
wmr.watch.cjs 25.5 kB 0 B

compressed-size-action

@andrewiggins
Copy link
Member

Is is possible to have both? I forget, does rollup support an array for outputs? (looking at their docs for 20s seems like no?) Wondering if we could output twice: once with inlineDynamicImports: false and once with inlineDynamicImports: true.

@developit
Copy link
Member Author

Could do, yeah. But then which would we ship?

@marvinhagemeister
Copy link
Member

I'm fine with either approach. The startup time seems to be more desirable, as that is likely the way it will be used by the majority of users.

@developit
Copy link
Member Author

I might try to get this splitted out so that it's just the main wmr.cjs and wmr.build.cjs, which is loaded for the build command or wmr --prebuild. At 25kb there's not much reason to split out watch and same goes for the http2 stuff I think.

@developit developit added the performance Performance optimizations label Nov 30, 2020
@developit developit modified the milestones: 1.1, 1.2 Dec 1, 2020
Base automatically changed from master to main January 22, 2021 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DRAFT Draft, not ready for merging performance Performance optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants