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

Method constructor

packages/compiler-cli/src/ngtsc/program.ts:50–136  ·  view source on GitHub ↗
(
    rootNames: ReadonlyArray<string>,
    private options: NgCompilerOptions,
    delegateHost: api.CompilerHost,
    oldProgram?: NgtscProgram,
  )

Source from the content-addressed store, hash-verified

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 );
97
98 this.incrementalStrategy =
99 oldProgram !== undefined
100 ? oldProgram.incrementalStrategy.toNextBuildStrategy()
101 : new TrackedIncrementalBuildStrategy();
102 const modifiedResourceFiles = new Set<AbsoluteFsPath>();
103 if (this.host.getModifiedResourceFiles !== undefined) {
104 const strings = this.host.getModifiedResourceFiles();
105 if (strings !== undefined) {
106 for (const fileString of strings) {
107 modifiedResourceFiles.add(absoluteFrom(fileString));

Callers

nothing calls this directly

Calls 15

retagAllTsFilesFunction · 0.90
absoluteFromFunction · 0.90
freshCompilationTicketFunction · 0.90
zeroedToNowMethod · 0.80
getCurrentProgramMethod · 0.80
fromTicketMethod · 0.80
phaseMethod · 0.65
wrapMethod · 0.65
inPhaseMethod · 0.65
memoryMethod · 0.65

Tested by

no test coverage detected