From b4149bb1bcaea00fb6aabc5bced6c6ec5f809aca Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 17 Apr 2026 08:40:13 +0000 Subject: [PATCH] fix(@angular/build): use rootDir for HMR component updates path resolution 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 --- .../build/src/tools/angular/compilation/aot-compilation.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts b/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts index 06a3f6e8c8d6..73462c2b3475 100644 --- a/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts +++ b/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts @@ -152,7 +152,10 @@ export class AotCompilation extends AngularCompilation { continue; } const componentFilename = node.getSourceFile().fileName; - let relativePath = relative(host.getCurrentDirectory(), componentFilename); + let relativePath = relative( + compilerOptions.rootDir ?? host.getCurrentDirectory(), + componentFilename, + ); if (relativePath.startsWith('..')) { relativePath = componentFilename; }