File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments