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
fix(core): ensure that autoRegisterModuleById registration in ɵɵdefineNgModule is not DCE-ed by closure #42529
Conversation
You can preview a04f0b0 at https://pr42529-a04f0b0.ngbuilds.io/. |
…eNgModule is not DCE-ed by closure Previously the autoRegisterModuleById registration was marked with noSideEffects wrapper to ensure that we don't end up retaining all NgModules. However the return value was not referenced by anything, so closure compiler removed it because it determined that this code has no side effects and is not referenced by anyone. This issue affects apps that use Closure Compiler and also rely on https://angular.io/api/core/getModuleFactory to retrieve factories by ID. This combination is used heavily in google3, especially in Pantheon. Fixes b/188453434
a04f0b0
to
de6c55a
Compare
You can preview de6c55a at https://pr42529-de6c55a.ngbuilds.io/. |
}; | ||
if (def.id != null) { | ||
noSideEffects(() => { | ||
return noSideEffects(() => { |
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.
Quick note (not a blocker for this PR, we can do that later): the PR description looks great and provide a useful insight into why this change is needed. I was thinking if we can partially reuse it as a comment in this function. Thank you.
…eNgModule is not DCE-ed by closure (#42529) Previously the autoRegisterModuleById registration was marked with noSideEffects wrapper to ensure that we don't end up retaining all NgModules. However the return value was not referenced by anything, so closure compiler removed it because it determined that this code has no side effects and is not referenced by anyone. This issue affects apps that use Closure Compiler and also rely on https://angular.io/api/core/getModuleFactory to retrieve factories by ID. This combination is used heavily in google3, especially in Pantheon. Fixes b/188453434 PR Close #42529
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. |
Previously the autoRegisterModuleById registration was marked with noSideEffects wrapper to ensure that we don't end up retaining all NgModules.
However the return value was not referenced by anything, so closure compiler removed it because it determined that this code has no side effects and is not referenced by anyone.
This issue affects apps that use Closure Compiler and also rely on https://angular.io/api/core/getModuleFactory to retrieve factories by ID. This combination is used heavily in google3, especially in Pantheon.