@@ -33,6 +33,7 @@ import { LogContexts, LogLevels, Logger } from 'bs-logger'
33
33
import bufferFrom = require( 'buffer-from' )
34
34
import stableStringify = require( 'fast-json-stable-stringify' )
35
35
import { readFileSync , writeFileSync } from 'fs'
36
+ import memoize = require( 'lodash.memoize' )
36
37
import mkdirp = require( 'mkdirp' )
37
38
import { basename , extname , join , relative } from 'path'
38
39
@@ -131,6 +132,7 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
131
132
...serviceHostDebugCtx ,
132
133
[ LogContexts . logLevel ] : LogLevels . trace ,
133
134
}
135
+
134
136
const serviceHost = {
135
137
getScriptFileNames : ( ) => Object . keys ( memoryCache . versions ) ,
136
138
getScriptVersion : ( fileName : string ) => {
@@ -157,12 +159,12 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
157
159
}
158
160
return ts . ScriptSnapshot . fromString ( contents )
159
161
} ,
160
- fileExists : ts . sys . fileExists ,
161
- readFile : logger . wrap ( serviceHostTraceCtx , 'readFile' , ts . sys . readFile ) ,
162
- readDirectory : ts . sys . readDirectory ,
163
- getDirectories : ts . sys . getDirectories ,
164
- directoryExists : ts . sys . directoryExists ,
165
- realpath : ts . sys . realpath ,
162
+ fileExists : memoize ( ts . sys . fileExists ) ,
163
+ readFile : logger . wrap ( serviceHostTraceCtx , 'readFile' , memoize ( ts . sys . readFile ) ) ,
164
+ readDirectory : memoize ( ts . sys . readDirectory ) ,
165
+ getDirectories : memoize ( ts . sys . getDirectories ) ,
166
+ directoryExists : memoize ( ts . sys . directoryExists ) ,
167
+ realpath : memoize ( ts . sys . realpath ! ) ,
166
168
getNewLine : ( ) => '\n' ,
167
169
getCurrentDirectory : ( ) => cwd ,
168
170
getCompilationSettings : ( ) => compilerOptions ,
0 commit comments