You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@MickL I tested the bundle size with webpack-bundle-analyzer as you suggested but I think it's not working properly.
The command used to test tree shaking in this project is npm run analyze:app which uses source-map-explorer, and if you double-check with the actual main.js size, it makes sense.
date-fns v2.19.0
date-fns v2.16.1
Issues with webpack-bundle-analyzer
I don't know the exact details about why the tool is not working properly, but I found a couple of places where they recommend aginst using it for Angular:
While the Angular CLI uses Webpack for some of its bundling, it also makes additional optimizations on top of Webpack. Because of these optimizations, it's important to use the source-map-explorer to test the final output and not the webpack-bundle-analyzer that is commonly used with Webpack based applications.
The angular team strongly recommends to only use source-map-explorer to analyze your bundle size instead of webpack-bundle-analyzer. According to them, webpack-bundle-analyzer and a few other similar tools doesn't give the actual info pertaining to angular build process.
Thanks for taking the time to explore this issue and for the v2.16.1 issue finding. I will add a note to the readme.
Cheers!
The documentation says:
I did this and checked with
ng build --stats-json
and then usingwebpack-bundle-analyzer
to see full 512kb ngx-date-fns is imported:But when I import just the specific pipe it works and ngx-date-fns is not even visible.
Dont try to reproduce with something newer than 2.16.1 since newer versions do not support tree shaking in the first place: date-fns/date-fns#2207
The text was updated successfully, but these errors were encountered: