| 37 | * command-line main() function or the Angular CLI. |
| 38 | */ |
| 39 | export class NgtscProgram implements api.Program { |
| 40 | readonly compiler: NgCompiler; |
| 41 | |
| 42 | /** |
| 43 | * The primary TypeScript program, which is used for analysis and emit. |
| 44 | */ |
| 45 | private tsProgram: ts.Program; |
| 46 | |
| 47 | private host: NgCompilerHost; |
| 48 | private incrementalStrategy: TrackedIncrementalBuildStrategy; |
| 49 | |
| 50 | constructor( |
| 51 | rootNames: ReadonlyArray<string>, |
| 52 | private options: NgCompilerOptions, |
| 53 | delegateHost: api.CompilerHost, |
| 54 | oldProgram?: NgtscProgram, |
| 55 | ) { |
| 56 | const perfRecorder = ActivePerfRecorder.zeroedToNow(); |
| 57 | |
| 58 | perfRecorder.phase(PerfPhase.Setup); |
| 59 | |
| 60 | // First, check whether the current TS version is supported. |
| 61 | if (!options.disableTypeScriptVersionCheck) { |
| 62 | verifySupportedTypeScriptVersion(); |
| 63 | } |
| 64 | |
| 65 | // In local compilation mode there are almost always (many) emit errors due to imports that |
| 66 | // cannot be resolved. So we should emit regardless. |
| 67 | if (options.compilationMode === 'experimental-local') { |
| 68 | options.noEmitOnError = false; |
| 69 | } |
| 70 | |
| 71 | const reuseProgram = oldProgram?.compiler.getCurrentProgram(); |
| 72 | this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null); |
| 73 | |
| 74 | if (reuseProgram !== undefined) { |
| 75 | // Prior to reusing the old program, restore shim tagging for all its `ts.SourceFile`s. |
| 76 | // TypeScript checks the `referencedFiles` of `ts.SourceFile`s for changes when evaluating |
| 77 | // incremental reuse of data from the old program, so it's important that these match in order |
| 78 | // to get the most benefit out of reuse. |
| 79 | retagAllTsFiles(reuseProgram); |
| 80 | } |
| 81 | |
| 82 | this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => |
| 83 | ts.createProgram(this.host.inputFiles, options, this.host, reuseProgram), |
| 84 | ); |
| 85 | |
| 86 | perfRecorder.phase(PerfPhase.Unaccounted); |
| 87 | perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate); |
| 88 | |
| 89 | this.host.postProgramCreationCleanup(); |
| 90 | |
| 91 | const programDriver = new TsCreateProgramDriver( |
| 92 | this.tsProgram, |
| 93 | this.host, |
| 94 | this.options, |
| 95 | this.host.shimExtensionPrefixes, |
| 96 | ); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…