MCPcopy Create free account
hub / github.com/angular/angular / run

Function run

packages/compiler-cli/preprocessor/ngp.ts:54–91  ·  view source on GitHub ↗
(compiler: HybridCompiler, options: RunOptions)

Source from the content-addressed store, hash-verified

52}
53
54export async function run(compiler: HybridCompiler, options: RunOptions): Promise<void> {
55 const {outDir = null, rootDir = '', tsconfigPath} = options;
56 const tracer = options.tracer ?? compiler.tracer;
57 const optimized = compiler.optimize && !compiler.emitDeclarationOnly;
58 const chunks = optimized ? compiler.analyzeOptimized() : compiler.analyze();
59 const results = tracer.enabled ? timeEachNext(tracer, chunks) : chunks;
60 try {
61 for await (const chunk of results) {
62 // Pre-bind all files and analyze cycles in the chunk
63 const chunkContext = await compiler.prepareChunk(chunk);
64
65 await Promise.all(
66 chunk.files.map((file) =>
67 processFile(file, outDir, compiler, options, chunkContext, rootDir, tracer),
68 ),
69 );
70 }
71 // Unconditional: even when the analyzer produced no chunks, option diagnostics (which don't
72 // depend on any file) still have to make it into the `.ngdiag.json`.
73 await tracer.sliceAsync(SpanKind.WriteDiagnostics, () =>
74 writeDiagnosticsFile(compiler, tsconfigPath),
75 );
76 } finally {
77 const {analyzer} = compiler;
78 if (tracer.enabled && analyzer.takePerf) {
79 try {
80 tracer.addAnalyzerPerf(
81 await tracer.sliceAsync(SpanKind.TakePerf, () => analyzer.takePerf!()),
82 );
83 } catch {
84 // The sidecar may already have exited (e.g. after a fatal error).
85 }
86 }
87 if (!options.keepAnalyzerAlive) {
88 tracer.slice(SpanKind.Close, () => analyzer.close());
89 }
90 }
91}
92
93/**
94 * Records each wait on `source.next()` as an `AwaitAnalysis` slice. Nothing else runs on the

Callers 1

main.tsFile · 0.70

Calls 12

timeEachNextFunction · 0.85
writeDiagnosticsFileFunction · 0.85
prepareChunkMethod · 0.80
mapMethod · 0.80
processFileFunction · 0.70
analyzeOptimizedMethod · 0.65
analyzeMethod · 0.65
sliceAsyncMethod · 0.65
addAnalyzerPerfMethod · 0.65
sliceMethod · 0.65
closeMethod · 0.65
allMethod · 0.45

Tested by

no test coverage detected