-
Notifications
You must be signed in to change notification settings - Fork 12k
unused classes got added in build, tree-shaking not working propely #15396
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
Comments
For your reference. Issue occurs in latest angular-cli version 8.2.2 also |
Hi, It is working fine in below environmen:
Please find working sample here- |
Hi all, I had a look at this issue and the reason why tree-shaking is not working is that Following this PR #14998 that landed in 8.2, we are using this field to determine whether build-optimizer should try to optimize a library, if no such field is found in the package.json, build-optimizer will not perform any optimizations on that library. It is also paramount to mention that the NB: In future optimizations related to TypeScript helpers replacements will be removed from build optimizer. |
HI @alan-agius4 , Thanks for your response. While adding |
This issue appears to have been resolved. If this has been closed in error, please let us know. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes
Description
Tree-shaking not working as expected
🔬 Reproducing steps
tree-shake.zip
run "npm i"
then give "ng build --prod"
check build source-
In that, "main-es5.js" and "main-es2015.js" has all modules, no tree shaking.
check string [getModuleName=function()] in bundle file , you can find it 61 times which means all other modules are imported even if they are not used. This shows unused classes are not getting tree-shaken.
🔥 Exception or Error
While using GridAllModule , build size is 1.8mb
While using GridModule which has less no of imported class, build size is same.
🌍 Your Environment
Anything else relevant?
#14585
#14577
The text was updated successfully, but these errors were encountered: