@@ -25,6 +25,7 @@ export interface TransformedConfiguration {
2525export abstract class TypeScriptCompilation extends AngularCompilation {
2626 static #angularCompilerCliModule?: typeof ng ;
2727 #cachedConfiguration?: TransformedConfiguration ;
28+ #cachedRootFiles?: readonly string [ ] ;
2829
2930 static async loadCompilerCli ( ) : Promise < typeof ng > {
3031 TypeScriptCompilation . #angularCompilerCliModule ??= await import ( '@angular/compiler-cli' ) ;
@@ -39,7 +40,14 @@ export abstract class TypeScriptCompilation extends AngularCompilation {
3940 ) : Promise < TransformedConfiguration > {
4041 // When `rootFiles` are explicitly provided (e.g., library builder), avoid re-parsing `tsconfig.json`
4142 // and walking the project directory tree via `readConfiguration` on every watch rebuild (~200-350ms on large libraries).
42- if ( compilerOptionOverrides ?. rootFiles ?. length && this . #cachedConfiguration) {
43+ const currentRootFiles = compilerOptionOverrides ?. rootFiles ;
44+ if (
45+ currentRootFiles &&
46+ this . #cachedConfiguration &&
47+ this . #cachedRootFiles &&
48+ this . #cachedRootFiles. length === currentRootFiles . length &&
49+ this . #cachedRootFiles. every ( ( file , index ) => file === currentRootFiles [ index ] )
50+ ) {
4351 return this . #cachedConfiguration;
4452 }
4553
@@ -96,8 +104,9 @@ export abstract class TypeScriptCompilation extends AngularCompilation {
96104 warnings,
97105 } ;
98106
99- if ( compilerOptionOverrides ?. rootFiles ?. length ) {
107+ if ( currentRootFiles ?. length ) {
100108 this . #cachedConfiguration = config ;
109+ this . #cachedRootFiles = currentRootFiles ;
101110 }
102111
103112 return config ;
@@ -112,6 +121,7 @@ export abstract class TypeScriptCompilation extends AngularCompilation {
112121 if ( / \. j s o n $ / i. test ( posixFile ) ) {
113122 // If a tsconfig changes, we need to re-read the configuration.
114123 this . #cachedConfiguration = undefined ;
124+ this . #cachedRootFiles = undefined ;
115125 }
116126 }
117127 }
0 commit comments