Skip to content
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

Closed

Conversation

IgorMinar
Copy link
Contributor

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.

@IgorMinar IgorMinar added type: bug/fix action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release labels Jun 9, 2021
@IgorMinar IgorMinar requested a review from alxhub June 9, 2021 16:44
@ngbot ngbot bot modified the milestone: Backlog Jun 9, 2021
@google-cla google-cla bot added the cla: yes label Jun 9, 2021
@mary-poppins
Copy link

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
@IgorMinar IgorMinar force-pushed the fix/defineNgModule-closure-bug branch from a04f0b0 to de6c55a Compare June 9, 2021 17:19
@mary-poppins
Copy link

You can preview de6c55a at https://pr42529-de6c55a.ngbuilds.io/.

@IgorMinar IgorMinar added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 9, 2021
};
if (def.id != null) {
noSideEffects(() => {
return noSideEffects(() => {
Copy link
Contributor

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.

alxhub pushed a commit that referenced this pull request Jun 9, 2021
…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
@alxhub alxhub closed this in 3961b3c Jun 9, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants