Skip to content

Commit 19a222e

Browse files
committed
addressed PR feedback
1 parent 7158a65 commit 19a222e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/compiler/tsc.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ namespace ts {
159159
let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation
160160
let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler
161161

162+
// This map stores and reuses results of fileExists check that happen inside 'createProgram'
163+
// This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times.
162164
let cachedExistingFiles: Map<boolean>;
163165
let hostFileExists: typeof compilerHost.fileExists;
164166

@@ -279,7 +281,7 @@ namespace ts {
279281
compilerHost.getSourceFile = getSourceFile;
280282

281283
hostFileExists = compilerHost.fileExists;
282-
compilerHost.fileExists = fileExists;
284+
compilerHost.fileExists = cachedFileExists;
283285
}
284286

285287
// reset the cache of existing files
@@ -295,7 +297,7 @@ namespace ts {
295297
reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
296298
}
297299

298-
function fileExists(fileName: string): boolean {
300+
function cachedFileExists(fileName: string): boolean {
299301
if (hasProperty(cachedExistingFiles, fileName)) {
300302
return cachedExistingFiles[fileName];
301303
}

0 commit comments

Comments
 (0)