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

Method constructor

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

Source from the content-addressed store, hash-verified

47 private incrementalStrategy: TrackedIncrementalBuildStrategy;
48
49 constructor(
50 rootNames: ReadonlyArray<string>,
51 private options: NgCompilerOptions,
52 delegateHost: api.CompilerHost,
53 oldProgram?: NgtscProgram,
54 ) {
55 const perfRecorder = ActivePerfRecorder.zeroedToNow();
56
57 perfRecorder.phase(PerfPhase.Setup);
58
59 // First, check whether the current TS version is supported.
60 if (!options.disableTypeScriptVersionCheck) {
61 verifySupportedTypeScriptVersion();
62 }
63
64 // In local compilation mode there are almost always (many) emit errors due to imports that
65 // cannot be resolved. So we should emit regardless.
66 if (options.compilationMode === 'experimental-local') {
67 options.noEmitOnError = false;
68 }
69
70 const reuseProgram = oldProgram?.compiler.getCurrentProgram();
71 this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
72
73 if (reuseProgram !== undefined) {
74 // Prior to reusing the old program, restore shim tagging for all its `ts.SourceFile`s.
75 // TypeScript checks the `referencedFiles` of `ts.SourceFile`s for changes when evaluating
76 // incremental reuse of data from the old program, so it's important that these match in order
77 // to get the most benefit out of reuse.
78 retagAllTsFiles(reuseProgram);
79 }
80
81 this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () =>
82 ts.createProgram(this.host.inputFiles, options, this.host, reuseProgram),
83 );
84
85 perfRecorder.phase(PerfPhase.Unaccounted);
86 perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
87
88 this.host.postProgramCreationCleanup();
89
90 const programDriver = new TsCreateProgramDriver(
91 this.tsProgram,
92 this.host,
93 this.options,
94 this.host.shimExtensionPrefixes,
95 );
96
97 this.incrementalStrategy =
98 oldProgram !== undefined
99 ? oldProgram.incrementalStrategy.toNextBuildStrategy()
100 : new TrackedIncrementalBuildStrategy();
101 const modifiedResourceFiles = new Set<AbsoluteFsPath>();
102 if (this.host.getModifiedResourceFiles !== undefined) {
103 const strings = this.host.getModifiedResourceFiles();
104 if (strings !== undefined) {
105 for (const fileString of strings) {
106 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