-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
ESM - Angular 10 Tree Shaking Support? #155
Comments
I don't know anything about Angular's build process I'm afraid. However, I imagine the optimization is an analysis of how loglevel's exports are used, and whether that means that some of loglevel's own dependencies or code can be omitted from your bundle. Since loglevel is tiny and doesn't have any dependencies at all, you can safely skip that anyway, it shouldn't make any significant difference. I don't imagine that this disables all optimizations in your build, just the optimization of your loglevel usage specifically. You can test this easily enough - try commenting our your import(s) of loglevel, and compare the bundle size to your normal build. If it makes no difference, the bundle size should differ only by the approximate size of loglevel itself, about 3KB. If it differs by a lot more that that, there's a larger problem where this is affecting your build optimizations. Assuming it indeed doesn't cause any problems, you can disable the warning using This could also be fixed by migrating loglevel to ESM - if you're really interested, I'd be open to a PR that added that as an output from the build process, but it's a bit complicated to do whilst preserving the existing setup. |
"This could also be fixed by migrating loglevel to ESM - if you're really interested, I'd be open to a PR that added that as an output from the build process, but it's a bit complicated to do whilst preserving the existing setup." Absolutely :) I was looking for an ESM version of loglevel. That should solve the issue. |
Ok, great! Feel free to open a PR for that, let me know if you have any questions en route. I do want to continue to support the existing UMD output, but I would be very happy to support more formats too if there's interest. |
WARNING in MyLogging.js depends on 'loglevel'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
How would I get rid of the warning? This happens during tree shaking and I'd like ascertain that optimization does take place?
Thank-you
The text was updated successfully, but these errors were encountered: