Skip to content

Commit 67389cf

Browse files
committed
Correctly update the ts, js extensions to handle when watching failed lookups so we are not doing extra tracking of actual paths
1 parent 377c4ce commit 67389cf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/compiler/resolutionCache.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ import {
6969
startsWith,
7070
stringContains,
7171
StringLiteralLike,
72+
supportedJSExtensionsFlat,
73+
supportedTSImplementationExtensions,
7274
trace,
7375
updateResolutionField,
7476
WatchDirectoryFlags,
@@ -298,13 +300,6 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
298300
moduleResolutionCache.getPackageJsonInfoCache(),
299301
);
300302

301-
/**
302-
* These are the extensions that failed lookup files will have by default,
303-
* any other extension of failed lookup will be store that path in custom failed lookup path
304-
* This helps in not having to comb through all resolutions when files are added/removed
305-
* Note that .d.ts file also has .d.ts extension hence will be part of default extensions
306-
*/
307-
const failedLookupDefaultExtensions = [Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx, Extension.Json];
308303
const customFailedLookupPaths = new Map<string, number>();
309304

310305
const directoryWatchesOfFailedLookups = new Map<string, DirectoryWatchesOfFailedLookup>();
@@ -764,7 +759,15 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
764759
}
765760

766761
function isPathWithDefaultFailedLookupExtension(path: Path) {
767-
return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
762+
/**
763+
* These are the extensions that failed lookup files will have by default,
764+
* any other extension of failed lookup will be store that path in custom failed lookup path
765+
* This helps in not having to comb through all resolutions when files are added/removed
766+
* Note that .d.ts file also has .d.ts extension hence will be part of default extensions
767+
*/
768+
return fileExtensionIsOneOf(path, supportedTSImplementationExtensions) ||
769+
fileExtensionIsOneOf(path, supportedJSExtensionsFlat) ||
770+
fileExtensionIs(path, Extension.Json);
768771
}
769772

770773
function watchFailedLookupLocationsOfExternalModuleResolutions<T extends ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName>(

0 commit comments

Comments
 (0)