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

Aot Bundle size #1538

Closed
olaf89 opened this issue Jan 22, 2017 · 14 comments
Closed

Aot Bundle size #1538

olaf89 opened this issue Jan 22, 2017 · 14 comments

Comments

@olaf89
Copy link

olaf89 commented Jan 22, 2017

Hello, while i was investigating my bundle size using aot build version. I noticed that even when using only one module from ng2-bootstrap the whole library is added as well as moment.js. This makes it quite heavy. Is there any way to improve this? For example changing commonjs modules to ES2015 so it can be tree shaken? Or do you have any other advice which would help with this issue?
This is how adding alert module influenced angular2 webpack starter bundle size (aot prod build) :
image

@valorkin
Copy link
Member

yes, it should work
I just checked, and ng core modules switched to es6, so we switch too

@valorkin valorkin self-assigned this Jan 23, 2017
@valorkin
Copy link
Member

waiting for CI to pass...

@valorkin
Copy link
Member

tests are passing but,
sourcemap-istanbul-instrumenter-loader failed

@valorkin valorkin reopened this Jan 23, 2017
@valorkin
Copy link
Member

released as v1.3.0
please try and update me

@olaf89
Copy link
Author

olaf89 commented Jan 23, 2017

Hey, wow thanks for such a quick feedback great stuff!
Unfortunately it does not seem to work as i would expect.
When importing only alert Module using angular2-webpack-starter (aot):
version: Bundle size
1.2.6: 126.8kb
1.3.0: 117.96kb
But overall looks like all not used modules are included in bundle.
Screen for 1.3.0:
ng-bootstrap1 3 0

@ctrl-brk
Copy link

@olaf89 Btw, what software did you use to produce that pic?

@olaf89
Copy link
Author

olaf89 commented Jan 23, 2017

@ctrl-brk im using webpack-bundle-analyzer

@GuskiS
Copy link

GuskiS commented Jan 31, 2017

Woah, nice tool :O
For me, ng2bs is using only used packages, not sure if it is because of tree shaking or because I'm importing it directly - ... from 'ng2-bootstrap/datepicker'

@valorkin
Copy link
Member

valorkin commented Feb 1, 2017

@olaf89 please try v1.3.2

@olaf89
Copy link
Author

olaf89 commented Feb 1, 2017

Hello,
@valorkin I tried but when importing from 'ng2-bootstrap' still whole library is included as well as moment.js.

BUT when tring to do it @GuskiS way (by importing from 'ng2-bootstrap/alert') the result is amazing:
not only all not used modules are dropped but also moment.js
Result:
bs-alert

@valorkin
Copy link
Member

valorkin commented Feb 1, 2017

This is awesome! Moment is required only by datepicker

@GuskiS
Copy link

GuskiS commented Feb 1, 2017

@valorkin Do you plan to remove momentjs in future?

@valorkin
Copy link
Member

valorkin commented Feb 2, 2017

More likely to make it optional
It provides localization, so it is pretty good

@alexlovato303
Copy link

@valorkin I recently had issues with moment in a webpack build for angular2. If it's included in an eager module webpack for some reason will not produce chunks for lazy routes

@olaf89 olaf89 closed this as completed Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants