-
Notifications
You must be signed in to change notification settings - Fork 12k
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
build-optimizer doesn't make Ivy's ngInjectorDef static property assignment available for DCE #15206
Comments
Yes this is a problem. I'm not sure option 2 (wrap the static property assignment in a new PURE IIFE) would work though. A pure function call with no arguments might just always get dropped. Will verify. We can also specialcase |
Note: to fully reproduce this, also modify
This makes the output readable. |
upon further discussion, we should be able to fix this by emitting the calls in the right order from ngtsc/ngcc - that's the option 1 I proposed above. @alxhub is looking into this. once we emit the code in the right order, the existing build-optimizer passes should be able to correctly optimize the code. |
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, the previous version in which this bug was not present was: ....no
Description
A clear and concise description of the problem...While debugging Ivy payload size issues, I noticed that
DeprecatedI18NPipesModule
was not being removed from hello world cli app, but only in the Ivy mode. Digging deeper I noticed that the build pipeline doesn't makengInjectorDef
assignments avalable for DCE.Snippet from the pre-terser code:
Terser won't remove this because it's a static property assignment. So while the right handside is marked as pure, the left handside might have a side effect and therefore will be retained.
I think this is a general problem we have in the pipeline where we generally expect that the static properties will be assigned within the PURE IIFE wrapped around a class, but in this case the assignment happens outside of that IIFE likely because of two other function calls (
ɵɵsetNgModuleScope
andsetClassMetadata
) that are emitted in between the class body and the static assignment:Because the static property assignment is now outside of the PURE class IIFE, the static property assignment is ineligible for DCE.
To fix this we have two options:
note the IIFE around the assignment marked as pure.
I'm slightly leaning towards the options number two just because it's more generic and could catch other issues.
🔬 Minimal Reproduction
review bundles and you'll see
DeprecatedI18NPipesModule
retained due to the pattern described above.🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: