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

Minimum bundle size? #111

Closed
kemsky opened this issue Oct 7, 2016 · 12 comments
Closed

Minimum bundle size? #111

kemsky opened this issue Oct 7, 2016 · 12 comments

Comments

@kemsky
Copy link

kemsky commented Oct 7, 2016

Hi, thanks for your efforts on this project.

I've tried to remove all code and modules from this project and check minimum bundle size. I get about 800kb minimum. As i know webpack2 should support tree-shaking, but i see the same bundle size as i get with webpack1. Does tree-shaking work in this config ? Is it necessary to configure additional plugins to make it work?

Thanks.

@DzmitryShylovich
Copy link

How did you build project?

Even with material and ngrx my final bundle is 209kb.

@kemsky
Copy link
Author

kemsky commented Oct 7, 2016

I guess you are talking about gzipped version?

@DzmitryShylovich
Copy link

ofc

@kemsky
Copy link
Author

kemsky commented Oct 7, 2016

My point is that there is no difference between webpack1 and webpack2 builds. They both produce ~800kb raw and ~200kb gzipped. It questions if there is any tree-shaking actually.

@DzmitryShylovich
Copy link

You should compare it to Rollup instead of webpack1.

@kemsky
Copy link
Author

kemsky commented Oct 7, 2016

If there is no difference between webpack1 and webpack2 then i don't have reason to migrate. Currently i'm checking angular-cli project to see how far it can go.

@DzmitryShylovich
Copy link

I've tried to remove all code and modules from this project and check minimum bundle size.

probably there's nothing to treeshake this is why u don't see any difference.

@kemsky
Copy link
Author

kemsky commented Oct 7, 2016

I was expecting angular source code to get tree-shaked because i believe that there is a lot of unused code in this scenario.

angular-cli

All builds make use of bundling, and using the --prod flag in ng build --prod or ng serve --prod will also make use of uglifying and tree-shaking functionality.

Result is ~700kb but it is not big difference and i could miss something during webpack expreiments.

M. Gechev mentions ~200kb raw size using rollup.

@DzmitryShylovich
Copy link

CLI uses webpack2 under the hood so its output should be very similar to this starter.

For now Rollup has the best treeshaking mechanism and should give you the smallest bundle.

@qdouble
Copy link
Owner

qdouble commented Oct 7, 2016

@kemsky If you remove preloading from the bare minimum branch so it compiles, it comes out to about ~700kb and 150KB gzipped. First of all, I'd be weary about the supposed differences of rollup builds, without using any extra tricks (closure compiler, and doing other types of hacks that are not standard), once you include polyfills, i.e shim, etc, it comes out to just about the same size. When I did a direct comparison apples to apples comparison myself, the difference was maybe 10-20kb gzipped. Also, the gzipped size is really what matters most... sometimes the rollup build may give a smaller minified size, while being about the same gzipped, so it doesn't make a practical difference.

Webpack is tree-shaking, it's just Angular doesn't currently get a lot smaller without non-standard hacks.

@qdouble
Copy link
Owner

qdouble commented Oct 7, 2016

@kemsky Also note that ie shim alone is like 24kb gzipped... I'm sure many of the rollup size statements are not even talking about a fully working app. Once you have a few modules and components, load up the polyfills, use i.e. shim and other stuff, a 50kb hello-world angular 2 app is a myth in terms of one that actually run in the browser without anything tacked on.

Make sure that any comparison between Webpack and rullup is comparing the size of the exact same thing. Same modules and components and including polyfills and shims. Also make sure you are comparing gzipped sizes. Once you look at it through that lens, I'm sure you'll see they are not far off unless you're doing some additional, non standard tricks.

@qdouble qdouble closed this as completed Oct 8, 2016
@kemsky
Copy link
Author

kemsky commented Oct 8, 2016

@qdouble, i understand you, its approximate comparison, my application is already ~ 1.5MB raw, so +- 50KB do not change anything really.

I just was surprised: AOT, tree-shaking, Webpack 2, online template compiler removed, modules, a lot of configuration - but bundle size is ~ same as it was several months ago when i created Webpack 1 build config. The only reason to use AOT is #11583. I'll wait until rollup/closure compiler get ready for production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants