-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Remove side effects to improve Ivy tree shaking in Closure #35846
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
Conversation
…inner function (angular#35769) This is useful for propagating return values without them being converted to a string. It still provides the same guarantees to Closure, which will assume that the function invoked is pure and can be tree-shaken accordingly. PR Close angular#35769 (cherry picked from commit 4052dd8)
…ular#35769) This causes all the `make*Decorator()` functions to be considered pure and to be eligible for associated tree shaking by Closure. PR Close angular#35769 (cherry picked from commit dc6a791)
) This marks the function are "pure" and eligible to be tree shaken by Closure. Without this, initializing `ngDevMode` is considered a side effect which prevents this function from being tree shaken and also any component which calls it. PR Close angular#35769 (cherry picked from commit ba36127)
…#35769) `ɵɵNgOnChangesFeature()` would set `ngInherit`, which is a side effect and also not necessary. This was pulled out to module scope so the function itself can be pure. Since it only curries another function, the call is entirely unnecessary. Updated the compiler to only generate a reference to this function, rather than a call to it, and removed the extra curry indirection. PR Close angular#35769 (cherry picked from commit 9cf85d2)
…r#35769) `ɵɵgetInheritedFactory()` is called from generated code for a component which extends another class. This function is detected by Closure to have a side effect and is not able to tree shake the component as a result. Marking it with `noSideEffects()` tells Closure it can remove this function under the relevant tree shaking conditions. PR Close angular#35769 (cherry picked from commit c195d22)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. already pre-reviewed in the original PR.
thanks!
global approval
…inner function (#35769) (#35846) This is useful for propagating return values without them being converted to a string. It still provides the same guarantees to Closure, which will assume that the function invoked is pure and can be tree-shaken accordingly. PR Close #35769 (cherry picked from commit 4052dd8) PR Close #35846
…35846) This marks the function are "pure" and eligible to be tree shaken by Closure. Without this, initializing `ngDevMode` is considered a side effect which prevents this function from being tree shaken and also any component which calls it. PR Close #35769 (cherry picked from commit ba36127) PR Close #35846
…#35846) `ɵɵNgOnChangesFeature()` would set `ngInherit`, which is a side effect and also not necessary. This was pulled out to module scope so the function itself can be pure. Since it only curries another function, the call is entirely unnecessary. Updated the compiler to only generate a reference to this function, rather than a call to it, and removed the extra curry indirection. PR Close #35769 (cherry picked from commit 9cf85d2) PR Close #35846
#35846) `ɵɵgetInheritedFactory()` is called from generated code for a component which extends another class. This function is detected by Closure to have a side effect and is not able to tree shake the component as a result. Marking it with `noSideEffects()` tells Closure it can remove this function under the relevant tree shaking conditions. PR Close #35769 (cherry picked from commit c195d22) PR Close #35846
Landed as 000c834 |
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
N/A - No easy way to verify that Closure tree shakes the relevant functions.
No docs to update.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Closure does not tree shake unused components built with Ivy.
Issue Number: http://b/149874196, http://b/149874638.
What is the new behavior?
Closure will now tree shake unused components built with Ivy.
Does this PR introduce a breaking change?
Other information
This is effectively identical to #35769, just targeting patch branch. I cherry-picked all the commits onto a new branch based on
9.0.x
.