From cae2d2a870aa59c020fd75a59ec2eefcf24c21f5 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Thu, 1 Oct 2026 07:26:01 +0000 Subject: [PATCH] perf(@angular/build): avoid invalidating Angular diagnostic cache on stylesheet change Component stylesheets (.css, .scss, .sass, .less) do not impact TypeScript semantic diagnostics or Angular template diagnostics. When a stylesheet dependency changes during watch rebuilds, avoid deleting the component's cached Angular diagnostics or marking the component source file as affected for diagnostics re-collection. --- .../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 ca74e721ba7d..e1205db0780a 100644 --- a/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts +++ b/packages/angular/build/src/tools/angular/compilation/aot-compilation.ts @@ -216,7 +216,10 @@ export class AotCompilation extends TypeScriptCompilation { // Also invalidate Angular diagnostics for a source file if component resources are modified if (this.#state && hostOptions.modifiedFiles?.size) { for (const resourceDependency of resourceDependencies) { - if (hostOptions.modifiedFiles.has(resourceDependency)) { + if ( + hostOptions.modifiedFiles.has(resourceDependency) && + !/\.(?:css|scss|sass|less)$/i.test(resourceDependency) + ) { this.#state.diagnosticCache.delete(sourceFile); // Also mark as affected in case changed template affects diagnostics affectedFiles.add(sourceFile);