File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,8 @@ namespace ts {
159
159
let timerHandleForRecompilation : number ; // Handle for 0.25s wait timer to trigger recompilation
160
160
let timerHandleForDirectoryChanges : number ; // Handle for 0.25s wait timer to trigger directory change handler
161
161
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.
162
164
let cachedExistingFiles : Map < boolean > ;
163
165
let hostFileExists : typeof compilerHost . fileExists ;
164
166
@@ -279,7 +281,7 @@ namespace ts {
279
281
compilerHost . getSourceFile = getSourceFile ;
280
282
281
283
hostFileExists = compilerHost . fileExists ;
282
- compilerHost . fileExists = fileExists ;
284
+ compilerHost . fileExists = cachedFileExists ;
283
285
}
284
286
285
287
// reset the cache of existing files
@@ -295,7 +297,7 @@ namespace ts {
295
297
reportWatchDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
296
298
}
297
299
298
- function fileExists ( fileName : string ) : boolean {
300
+ function cachedFileExists ( fileName : string ) : boolean {
299
301
if ( hasProperty ( cachedExistingFiles , fileName ) ) {
300
302
return cachedExistingFiles [ fileName ] ;
301
303
}
You can’t perform that action at this time.
0 commit comments