()
| 177 | |
| 178 | // Invoked to perform initial compilation or re-compilation in watch mode |
| 179 | function doCompilation(): ReadonlyArray<ts.Diagnostic> { |
| 180 | if (!cachedOptions) { |
| 181 | cachedOptions = host.readConfiguration(); |
| 182 | } |
| 183 | if (cachedOptions.errors && cachedOptions.errors.length) { |
| 184 | host.reportDiagnostics(cachedOptions.errors); |
| 185 | return cachedOptions.errors; |
| 186 | } |
| 187 | const startTime = Date.now(); |
| 188 | if (!cachedCompilerHost) { |
| 189 | cachedCompilerHost = host.createCompilerHost(cachedOptions.options); |
| 190 | const originalWriteFileCallback = cachedCompilerHost.writeFile; |
| 191 | cachedCompilerHost.writeFile = function ( |
| 192 | fileName: string, |
| 193 | data: string, |
| 194 | writeByteOrderMark: boolean, |
| 195 | onError?: (message: string) => void, |
| 196 | sourceFiles: ReadonlyArray<ts.SourceFile> = [], |
| 197 | ) { |
| 198 | ignoreFilesForWatch.add(path.normalize(fileName)); |
| 199 | return originalWriteFileCallback(fileName, data, writeByteOrderMark, onError, sourceFiles); |
| 200 | }; |
| 201 | const originalFileExists = cachedCompilerHost.fileExists; |
| 202 | cachedCompilerHost.fileExists = function (fileName: string) { |
| 203 | const ce = cacheEntry(fileName); |
| 204 | if (ce.exists == null) { |
| 205 | ce.exists = originalFileExists.call(this, fileName); |
| 206 | } |
| 207 | return ce.exists!; |
| 208 | }; |
| 209 | const originalGetSourceFile = cachedCompilerHost.getSourceFile; |
| 210 | cachedCompilerHost.getSourceFile = function ( |
| 211 | fileName: string, |
| 212 | languageVersion: ts.ScriptTarget, |
| 213 | ) { |
| 214 | const ce = cacheEntry(fileName); |
| 215 | if (!ce.sf) { |
| 216 | ce.sf = originalGetSourceFile.call(this, fileName, languageVersion); |
| 217 | } |
| 218 | return ce.sf!; |
| 219 | }; |
| 220 | const originalReadFile = cachedCompilerHost.readFile; |
| 221 | cachedCompilerHost.readFile = function (fileName: string) { |
| 222 | const ce = cacheEntry(fileName); |
| 223 | if (ce.content == null) { |
| 224 | ce.content = originalReadFile.call(this, fileName); |
| 225 | } |
| 226 | return ce.content!; |
| 227 | }; |
| 228 | // Provide access to the file paths that triggered this rebuild |
| 229 | cachedCompilerHost.getModifiedResourceFiles = function () { |
| 230 | if (timerHandleForRecompilation === undefined) { |
| 231 | return undefined; |
| 232 | } |
| 233 | return timerHandleForRecompilation.modifiedResourceFiles; |
| 234 | }; |
| 235 | } |
| 236 | ignoreFilesForWatch.clear(); |
no test coverage detected
searching dependent graphs…