Skip to content

fix(@angular/build): use rootDir for HMR component updates path resolution#33016

Merged
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:hmr-root-dir
Apr 17, 2026
Merged

fix(@angular/build): use rootDir for HMR component updates path resolution#33016
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:hmr-root-dir

Conversation

@alan-agius4
Copy link
Copy Markdown
Collaborator

Use compilerOptions.rootDir when calculating the relative path for HMR component updates, falling back to the current directory if not set. This ensures correct path resolution when rootDir is configured in tsconfig.

Closes #33005 and closes #32998

…ution

Use `compilerOptions.rootDir` when calculating the relative path for HMR component updates, falling back to the current directory if not set. This ensures correct path resolution when `rootDir` is configured in `tsconfig`.

Closes angular#33005 and closes angular#32998
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the path resolution logic in the AotCompilation class to prioritize the rootDir from compiler options when calculating relative paths for components. I have no feedback to provide as there were no review comments to evaluate.

@alan-agius4 alan-agius4 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 and removed area: @angular/build labels Apr 17, 2026
@alan-agius4 alan-agius4 requested a review from clydin April 17, 2026 08:45
const componentFilename = node.getSourceFile().fileName;
let relativePath = relative(host.getCurrentDirectory(), componentFilename);
let relativePath = relative(
compilerOptions.rootDir ?? host.getCurrentDirectory(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is compilerOptions.rootDir absolute here?

Copy link
Copy Markdown
Collaborator Author

@alan-agius4 alan-agius4 Apr 17, 2026

Choose a reason for hiding this comment

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

Yes, it's always fully resolved by tsc.

@alan-agius4 alan-agius4 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 Apr 17, 2026
@alan-agius4 alan-agius4 merged commit 59803b1 into angular:main Apr 17, 2026
39 checks passed
@alan-agius4 alan-agius4 deleted the hmr-root-dir branch April 17, 2026 13:54
@alan-agius4
Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker 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 component updates silently fail in multi-project workspaces HMR not working when setting "rootDir": "./src" in tsconfig.json

2 participants