Skip to content

Handle const enums in HMR replacement function#59815

Closed
crisbeto wants to merge 3 commits intoangular:mainfrom
crisbeto:hmr-const-enum
Closed

Handle const enums in HMR replacement function#59815
crisbeto wants to merge 3 commits intoangular:mainfrom
crisbeto:hmr-const-enum

Conversation

@crisbeto
Copy link
Copy Markdown
Member

Includes the following changes that allow us to generate HMR replacement functions that depend on const enums.

fix(compiler-cli): handle enum members without initializers in partial evaluator

Fixes that the partial evaluator was interpreting initializer-less enum members as undefined. In this case the value is the same as the index.

fix(compiler-cli): handle const enums used inside HMR data

When we generate an HMR replacement function, we determine which locals from the file are used and we pass them by reference. This works fine in most cases, but breaks down for const enums which don't have a runtime representation.

These changes work around the issue by passing in all the values as an object literal.

fix(compiler-cli): gracefully fall back if const enum cannot be passed through

Adds some logic so that if we can't produce a runtime representation of an enum, the dev server can fall back to refreshing the page.

Fixes #59800.

…l evaluator

Fixes that the partial evaluator was interpreting initializer-less enum members as undefined. In this case the value is the same as the index.
When we generate an HMR replacement function, we determine which locals from the file are used and we pass them by reference. This works fine in most cases, but breaks down for const enums which don't have a runtime representation.

These changes work around the issue by passing in all the values as an object literal.

Fixes angular#59800.
…d through

Adds some logic so that if we can't produce a runtime representation of an enum, the dev server can fall back to refreshing the page.
@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 31, 2025
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Jan 31, 2025
@ngbot ngbot bot added this to the Backlog milestone Jan 31, 2025
@crisbeto crisbeto marked this pull request as ready for review January 31, 2025 09:18
@crisbeto crisbeto removed the request for review from clydin January 31, 2025 16:53
@crisbeto crisbeto 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 Jan 31, 2025
@alxhub
Copy link
Copy Markdown
Member

alxhub commented Feb 3, 2025

This PR was merged into the repository by commit a971360.

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

alxhub pushed a commit that referenced this pull request Feb 3, 2025
…l evaluator (#59815)

Fixes that the partial evaluator was interpreting initializer-less enum members as undefined. In this case the value is the same as the index.

PR Close #59815
alxhub pushed a commit that referenced this pull request Feb 3, 2025
When we generate an HMR replacement function, we determine which locals from the file are used and we pass them by reference. This works fine in most cases, but breaks down for const enums which don't have a runtime representation.

These changes work around the issue by passing in all the values as an object literal.

Fixes #59800.

PR Close #59815
alxhub pushed a commit that referenced this pull request Feb 3, 2025
…d through (#59815)

Adds some logic so that if we can't produce a runtime representation of an enum, the dev server can fall back to refreshing the page.

PR Close #59815
@alxhub alxhub closed this in 03bcd30 Feb 3, 2025
alxhub pushed a commit that referenced this pull request Feb 3, 2025
When we generate an HMR replacement function, we determine which locals from the file are used and we pass them by reference. This works fine in most cases, but breaks down for const enums which don't have a runtime representation.

These changes work around the issue by passing in all the values as an object literal.

Fixes #59800.

PR Close #59815
alxhub pushed a commit that referenced this pull request Feb 3, 2025
…d through (#59815)

Adds some logic so that if we can't produce a runtime representation of an enum, the dev server can fall back to refreshing the page.

PR Close #59815
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…l evaluator (angular#59815)

Fixes that the partial evaluator was interpreting initializer-less enum members as undefined. In this case the value is the same as the index.

PR Close angular#59815
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…9815)

When we generate an HMR replacement function, we determine which locals from the file are used and we pass them by reference. This works fine in most cases, but breaks down for const enums which don't have a runtime representation.

These changes work around the issue by passing in all the values as an object literal.

Fixes angular#59800.

PR Close angular#59815
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…d through (angular#59815)

Adds some logic so that if we can't produce a runtime representation of an enum, the dev server can fall back to refreshing the page.

PR Close angular#59815
@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 Mar 6, 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.

HMR breaks when using a const enum value inside decorator metadata

3 participants