@@ -53,6 +53,7 @@ export abstract class TypeScriptCompilation extends AngularCompilation {
5353 return this . #cachedConfiguration;
5454 }
5555
56+ // TODO(alanagius): remove casting when @angular/compiler-cli exports the correct typings.
5657 const { readConfiguration } = ( await TypeScriptCompilation . loadCompilerCli ( ) ) as typeof ng & {
5758 readConfiguration (
5859 project : string ,
@@ -119,7 +120,7 @@ export abstract class TypeScriptCompilation extends AngularCompilation {
119120 extendedConfigFiles : [ ...this . #extendedConfigCache. keys ( ) ] ,
120121 } ;
121122
122- if ( currentRootFiles ?. length ) {
123+ if ( config . extendedConfigFiles ?. length && currentRootFiles ?. length ) {
123124 this . #cachedConfiguration = config ;
124125 this . #cachedRootFiles = currentRootFiles ;
125126 }
@@ -133,15 +134,25 @@ export abstract class TypeScriptCompilation extends AngularCompilation {
133134 for ( const file of files ) {
134135 const posixFile = toPosixPath ( file ) ;
135136 this . sourceFiles . delete ( posixFile ) ;
136- if (
137- / \. j s o n $ / i. test ( posixFile ) ||
138- this . #extendedConfigCache. has ( posixFile ) ||
139- this . #extendedConfigCache. has ( canonicalizePath ( posixFile ) )
140- ) {
141- // If a tsconfig changes, we need to re-read the configuration.
142- this . #cachedConfiguration = undefined ;
143- this . #cachedRootFiles = undefined ;
144- this . #extendedConfigCache. clear ( ) ;
137+
138+ if ( this . #extendedConfigCache. size ) {
139+ let cacheKey : string | undefined ;
140+ if ( this . #extendedConfigCache. has ( posixFile ) ) {
141+ cacheKey = posixFile ;
142+ } else {
143+ // TypeScript lowercases the keys of the extended config cache on case-insensitive operating systems.
144+ const lowerCasedPosixFile = posixFile . toLowerCase ( ) ;
145+ if ( this . #extendedConfigCache. has ( lowerCasedPosixFile ) ) {
146+ cacheKey = lowerCasedPosixFile ;
147+ }
148+ }
149+
150+ if ( cacheKey ) {
151+ // If a tsconfig changes, we need to re-read the configuration.
152+ this . #cachedConfiguration = undefined ;
153+ this . #cachedRootFiles = undefined ;
154+ this . #extendedConfigCache. delete ( cacheKey ) ;
155+ }
145156 }
146157 }
147158 }
0 commit comments