@@ -854,6 +854,7 @@ export interface PerNonRelativeNameCache<T> {
854
854
export interface ModuleResolutionCache extends PerDirectoryResolutionCache < ResolvedModuleWithFailedLookupLocations > , NonRelativeModuleNameResolutionCache , PackageJsonInfoCache {
855
855
getPackageJsonInfoCache ( ) : PackageJsonInfoCache ;
856
856
/** @internal */ clearAllExceptPackageJsonInfoCache ( ) : void ;
857
+ /** @internal */ optionsToRedirectsKey : Map < CompilerOptions , RedirectsCacheKey > ;
857
858
}
858
859
859
860
/**
@@ -905,10 +906,11 @@ export interface CacheWithRedirects<K, V> {
905
906
}
906
907
907
908
/** @internal */
908
- export function createCacheWithRedirects < K , V > ( ownOptions : CompilerOptions | undefined ) : CacheWithRedirects < K , V > {
909
- type RedirectsCacheKey = string & { __compilerOptionsKey : any ; } ;
909
+ export type RedirectsCacheKey = string & { __compilerOptionsKey : any ; } ;
910
+
911
+ /** @internal */
912
+ export function createCacheWithRedirects < K , V > ( ownOptions : CompilerOptions | undefined , optionsToRedirectsKey : Map < CompilerOptions , RedirectsCacheKey > ) : CacheWithRedirects < K , V > {
910
913
const redirectsMap = new Map < CompilerOptions , Map < K , V > > ( ) ;
911
- const optionsToRedirectsKey = new Map < CompilerOptions , RedirectsCacheKey > ( ) ;
912
914
const redirectsKeyToMap = new Map < RedirectsCacheKey , Map < K , V > > ( ) ;
913
915
let ownMap = new Map < K , V > ( ) ;
914
916
if ( ownOptions ) redirectsMap . set ( ownOptions , ownMap ) ;
@@ -1011,8 +1013,13 @@ function getOrCreateCache<K, V>(cacheWithRedirects: CacheWithRedirects<K, V>, re
1011
1013
return result ;
1012
1014
}
1013
1015
1014
- function createPerDirectoryResolutionCache < T > ( currentDirectory : string , getCanonicalFileName : GetCanonicalFileName , options : CompilerOptions | undefined ) : PerDirectoryResolutionCache < T > {
1015
- const directoryToModuleNameMap = createCacheWithRedirects < Path , ModeAwareCache < T > > ( options ) ;
1016
+ function createPerDirectoryResolutionCache < T > (
1017
+ currentDirectory : string ,
1018
+ getCanonicalFileName : GetCanonicalFileName ,
1019
+ options : CompilerOptions | undefined ,
1020
+ optionsToRedirectsKey : Map < CompilerOptions , RedirectsCacheKey > ,
1021
+ ) : PerDirectoryResolutionCache < T > {
1022
+ const directoryToModuleNameMap = createCacheWithRedirects < Path , ModeAwareCache < T > > ( options , optionsToRedirectsKey ) ;
1016
1023
return {
1017
1024
getFromDirectoryCache,
1018
1025
getOrCreateCacheForDirectory,
@@ -1114,8 +1121,9 @@ function createNonRelativeNameResolutionCache<T>(
1114
1121
getCanonicalFileName : ( s : string ) => string ,
1115
1122
options : CompilerOptions | undefined ,
1116
1123
getResolvedFileName : ( result : T ) => string | undefined ,
1124
+ optionsToRedirectsKey : Map < CompilerOptions , RedirectsCacheKey > ,
1117
1125
) : NonRelativeNameResolutionCache < T > {
1118
- const moduleNameToDirectoryMap = createCacheWithRedirects < ModeAwareCacheKey , PerNonRelativeNameCache < T > > ( options ) ;
1126
+ const moduleNameToDirectoryMap = createCacheWithRedirects < ModeAwareCacheKey , PerNonRelativeNameCache < T > > ( options , optionsToRedirectsKey ) ;
1119
1127
return {
1120
1128
getFromNonRelativeNameCache,
1121
1129
getOrCreateCacheForNonRelativeName,
@@ -1216,20 +1224,29 @@ function createNonRelativeNameResolutionCache<T>(
1216
1224
interface ModuleOrTypeReferenceResolutionCache < T > extends PerDirectoryResolutionCache < T > , NonRelativeNameResolutionCache < T > , PackageJsonInfoCache {
1217
1225
getPackageJsonInfoCache ( ) : PackageJsonInfoCache ;
1218
1226
clearAllExceptPackageJsonInfoCache ( ) : void ;
1227
+ optionsToRedirectsKey : Map < CompilerOptions , RedirectsCacheKey > ;
1219
1228
}
1220
1229
function createModuleOrTypeReferenceResolutionCache < T > (
1221
1230
currentDirectory : string ,
1222
1231
getCanonicalFileName : ( s : string ) => string ,
1223
1232
options : CompilerOptions | undefined ,
1224
1233
packageJsonInfoCache : PackageJsonInfoCache | undefined ,
1225
1234
getResolvedFileName : ( result : T ) => string | undefined ,
1235
+ optionsToRedirectsKey : Map < CompilerOptions , RedirectsCacheKey > | undefined ,
1226
1236
) : ModuleOrTypeReferenceResolutionCache < T > {
1227
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache < T > ( currentDirectory , getCanonicalFileName , options ) ;
1237
+ optionsToRedirectsKey ??= new Map ( ) ;
1238
+ const perDirectoryResolutionCache = createPerDirectoryResolutionCache < T > (
1239
+ currentDirectory ,
1240
+ getCanonicalFileName ,
1241
+ options ,
1242
+ optionsToRedirectsKey ,
1243
+ ) ;
1228
1244
const nonRelativeNameResolutionCache = createNonRelativeNameResolutionCache (
1229
1245
currentDirectory ,
1230
1246
getCanonicalFileName ,
1231
1247
options ,
1232
1248
getResolvedFileName ,
1249
+ optionsToRedirectsKey ,
1233
1250
) ;
1234
1251
packageJsonInfoCache ??= createPackageJsonInfoCache ( currentDirectory , getCanonicalFileName ) ;
1235
1252
@@ -1241,6 +1258,7 @@ function createModuleOrTypeReferenceResolutionCache<T>(
1241
1258
update,
1242
1259
getPackageJsonInfoCache : ( ) => packageJsonInfoCache ! ,
1243
1260
clearAllExceptPackageJsonInfoCache,
1261
+ optionsToRedirectsKey,
1244
1262
} ;
1245
1263
1246
1264
function clear ( ) {
@@ -1264,13 +1282,29 @@ export function createModuleResolutionCache(
1264
1282
getCanonicalFileName : ( s : string ) => string ,
1265
1283
options ?: CompilerOptions ,
1266
1284
packageJsonInfoCache ?: PackageJsonInfoCache ,
1285
+ ) : ModuleResolutionCache ;
1286
+ /** @internal */
1287
+ export function createModuleResolutionCache (
1288
+ currentDirectory : string ,
1289
+ getCanonicalFileName : ( s : string ) => string ,
1290
+ options ?: CompilerOptions ,
1291
+ packageJsonInfoCache ?: PackageJsonInfoCache ,
1292
+ optionsToRedirectsKey ?: Map < CompilerOptions , RedirectsCacheKey > ,
1293
+ ) : ModuleResolutionCache ;
1294
+ export function createModuleResolutionCache (
1295
+ currentDirectory : string ,
1296
+ getCanonicalFileName : ( s : string ) => string ,
1297
+ options ?: CompilerOptions ,
1298
+ packageJsonInfoCache ?: PackageJsonInfoCache ,
1299
+ optionsToRedirectsKey ?: Map < CompilerOptions , RedirectsCacheKey > ,
1267
1300
) : ModuleResolutionCache {
1268
1301
const result = createModuleOrTypeReferenceResolutionCache (
1269
1302
currentDirectory ,
1270
1303
getCanonicalFileName ,
1271
1304
options ,
1272
1305
packageJsonInfoCache ,
1273
1306
getOriginalOrResolvedModuleFileName ,
1307
+ optionsToRedirectsKey ,
1274
1308
) as ModuleResolutionCache ;
1275
1309
result . getOrCreateCacheForModuleName = ( nonRelativeName , mode , redirectedReference ) => result . getOrCreateCacheForNonRelativeName ( nonRelativeName , mode , redirectedReference ) ;
1276
1310
return result ;
@@ -1281,13 +1315,29 @@ export function createTypeReferenceDirectiveResolutionCache(
1281
1315
getCanonicalFileName : ( s : string ) => string ,
1282
1316
options ?: CompilerOptions ,
1283
1317
packageJsonInfoCache ?: PackageJsonInfoCache ,
1318
+ ) : TypeReferenceDirectiveResolutionCache ;
1319
+ /** @internal */
1320
+ export function createTypeReferenceDirectiveResolutionCache (
1321
+ currentDirectory : string ,
1322
+ getCanonicalFileName : ( s : string ) => string ,
1323
+ options ?: CompilerOptions ,
1324
+ packageJsonInfoCache ?: PackageJsonInfoCache ,
1325
+ optionsToRedirectsKey ?: Map < CompilerOptions , RedirectsCacheKey > ,
1326
+ ) : TypeReferenceDirectiveResolutionCache ;
1327
+ export function createTypeReferenceDirectiveResolutionCache (
1328
+ currentDirectory : string ,
1329
+ getCanonicalFileName : ( s : string ) => string ,
1330
+ options ?: CompilerOptions ,
1331
+ packageJsonInfoCache ?: PackageJsonInfoCache ,
1332
+ optionsToRedirectsKey ?: Map < CompilerOptions , RedirectsCacheKey > ,
1284
1333
) : TypeReferenceDirectiveResolutionCache {
1285
1334
return createModuleOrTypeReferenceResolutionCache (
1286
1335
currentDirectory ,
1287
1336
getCanonicalFileName ,
1288
1337
options ,
1289
1338
packageJsonInfoCache ,
1290
- getOriginalOrResolvedTypeReferenceFileName
1339
+ getOriginalOrResolvedTypeReferenceFileName ,
1340
+ optionsToRedirectsKey ,
1291
1341
) ;
1292
1342
}
1293
1343
0 commit comments