Skip to content

fix(compiler-cli): disable tree shaking during HMR#59595

Closed
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:59581/hmr-tree-shaking
Closed

fix(compiler-cli): disable tree shaking during HMR#59595
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:59581/hmr-tree-shaking

Conversation

@crisbeto
Copy link
Copy Markdown
Member

@crisbeto crisbeto commented Jan 17, 2025

When HMR is enabled, we need to capture the dependencies used in a template and forward them to the HMR replacement function. One half of this process is static, meaning that we can't change it after the initial compilation. Tree shaking becomes a problem in such a case, because the user can change the template in a way that changes the set of dependencies which will start mismatching with the static part of the HMR code.

These changes disable the tree shaking when HMR is enabled to ensure that the dependencies stay stable.

Fixes #59581.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Jan 17, 2025
@crisbeto crisbeto requested a review from JoostK January 17, 2025 12:38
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Jan 17, 2025
@ngbot ngbot bot added this to the Backlog milestone Jan 17, 2025
When HMR is enabled, we need to capture the dependencies used in a template and forward them to the HMR replacement function. One half of this process is static, meaning that we can't change it after the initial compilation. Tree shaking becomes a problem in such a case, because the user can change the template in a way that changes the set of dependencies which will start matching with the static part of the HMR code.

These changes disable the tree shaking when HMR is enabled to ensure that the dependencies stay stable.

Fixes angular#59581.
@crisbeto crisbeto force-pushed the 59581/hmr-tree-shaking branch from 73e2d66 to fafe228 Compare January 17, 2025 18:03
@AndrewKushnir AndrewKushnir requested a review from alxhub January 17, 2025 20:33
@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 17, 2025
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jan 18, 2025
@pkozlowski-opensource
Copy link
Copy Markdown
Member

This PR was merged into the repository by commit f9b13e4.

The changes were merged into the following branches: main, 19.1.x

pkozlowski-opensource pushed a commit that referenced this pull request Jan 20, 2025
When HMR is enabled, we need to capture the dependencies used in a template and forward them to the HMR replacement function. One half of this process is static, meaning that we can't change it after the initial compilation. Tree shaking becomes a problem in such a case, because the user can change the template in a way that changes the set of dependencies which will start matching with the static part of the HMR code.

These changes disable the tree shaking when HMR is enabled to ensure that the dependencies stay stable.

Fixes #59581.

PR Close #59595
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
When HMR is enabled, we need to capture the dependencies used in a template and forward them to the HMR replacement function. One half of this process is static, meaning that we can't change it after the initial compilation. Tree shaking becomes a problem in such a case, because the user can change the template in a way that changes the set of dependencies which will start matching with the static part of the HMR code.

These changes disable the tree shaking when HMR is enabled to ensure that the dependencies stay stable.

Fixes angular#59581.

PR Close angular#59595
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 Feb 20, 2025
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: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(HMR): removing components selectors from a template causes inconsistent behavior with other components in template

5 participants