MCPcopy Index your code
hub / github.com/angular/angular / doCompilation

Function doCompilation

packages/compiler-cli/src/perform_watch.ts:179–271  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 2

performWatchCompilationFunction · 0.85
recompileFunction · 0.85

Calls 12

performCompilationFunction · 0.90
exitCodeFromResultFunction · 0.90
createMessageDiagnosticFunction · 0.90
cacheEntryFunction · 0.85
readConfigurationMethod · 0.65
reportDiagnosticsMethod · 0.65
createCompilerHostMethod · 0.65
addMethod · 0.65
normalizeMethod · 0.65
createEmitCallbackMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…