Skip to content

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 10, 2024

Includes a couple of commits that enable the compiler to output calls that will enable HMR for component classes, as well as fix for file paths in setClassDebugInfo.

refactor(compiler): add logic to generate the HMR initializer

Adds the logic that will generate the import expression that will initializer HMR for a specific component.

refactor(compiler-cli): output HMR initializer code

Adds the logic to the compiler that will output the HMR initializer code for each component, if enabled.

fix(compiler-cli): incorrectly generating relative file paths on case-insensitive platforms

We're using path.relative to compute a relative path between a SourceFile and the one of the rootDirs. The problem is that the rootDirs get passed through getCanonicalFileName which lowercases the path in some platforms, while SourceFile.fileName is always case-insensitive. This yields a path outside of the project which we were ignoring.

This change passes the SourceFile.fileName before passing it through path.relative to ensure that we get a valid result.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 10, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 10, 2024
@angular-robot angular-robot bot added area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 10, 2024
@crisbeto crisbeto requested a review from clydin October 10, 2024 14:30
@crisbeto crisbeto marked this pull request as ready for review October 10, 2024 14:30
@pullapprove pullapprove bot requested a review from josephperrott October 10, 2024 14:30
Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: bazel

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

(forgot to choose approve)

Reviewed-for: bazel

Adds the logic that will generate the `import` expression that will initializer HMR for a specific component.
@crisbeto crisbeto force-pushed the hmr-initializer-call branch from ceff38e to f1a5492 Compare October 10, 2024 17:34
@angular-robot angular-robot bot added area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 10, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 10, 2024
@crisbeto crisbeto force-pushed the hmr-initializer-call branch from f1a5492 to 64b99bb Compare October 10, 2024 17:52
@angular-robot angular-robot bot added area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 10, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 10, 2024
Adds the logic to the compiler that will output the HMR initializer code for each component, if enabled.
…-insensitive platforms

We're using `path.relative` to compute a relative path between a `SourceFile` and the one of the `rootDirs`. The problem is that the `rootDirs` get passed through `getCanonicalFileName` which lowercases the path in some platforms, while `SourceFile.fileName` is always case-insensitive. This yields a path outside of the project which we were ignoring.

This change passes the `SourceFile.fileName` before passing it through `path.relative` to ensure that we get a valid result.
@crisbeto crisbeto force-pushed the hmr-initializer-call branch from 64b99bb to 4f68307 Compare October 10, 2024 19:17
@angular-robot angular-robot bot added area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 10, 2024
@ngbot ngbot bot removed this from the Backlog milestone Oct 10, 2024
@ngbot ngbot bot added this to the Backlog milestone Oct 10, 2024
@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 Oct 11, 2024
@crisbeto crisbeto removed the request for review from clydin October 11, 2024 05:09
@devversion
Copy link
Member

This PR was merged into the repository by commit fb44323.

The changes were merged into the following branches: main

devversion pushed a commit that referenced this pull request Oct 11, 2024
Adds the logic to the compiler that will output the HMR initializer code for each component, if enabled.

PR Close #58150
devversion pushed a commit that referenced this pull request Oct 11, 2024
…-insensitive platforms (#58150)

We're using `path.relative` to compute a relative path between a `SourceFile` and the one of the `rootDirs`. The problem is that the `rootDirs` get passed through `getCanonicalFileName` which lowercases the path in some platforms, while `SourceFile.fileName` is always case-insensitive. This yields a path outside of the project which we were ignoring.

This change passes the `SourceFile.fileName` before passing it through `path.relative` to ensure that we get a valid result.

PR Close #58150
@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 Nov 11, 2024
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: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants