refactor(@angular/build): eliminate NoopCompilation and introduce primary and secondary compilation contexts - #33978
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Angular compilation context structure by removing NoopCompilation and introducing an abstract AngularCompilationContext with two concrete implementations: PrimaryCompilationContext and SecondaryCompilationContext. This allows secondary compilation contexts to delegate compiler options and readiness checks to the primary context. The review feedback highlights two important issues in PrimaryCompilationContext: a potential hang in getCompilerOptions() if compilation is no longer pending but options are undefined, and the need to clear cached compiler options when a new compilation cycle is marked as in progress to avoid serving stale options.
c4158b4 to
1e0f46c
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the Angular compilation context by replacing NoopCompilation with a SecondaryCompilationContext and introducing a PrimaryCompilationContext under an abstract AngularCompilationContext. This allows secondary contexts to delegate compiler options and ready states to the primary context. The review feedback suggests explicitly clearing this.#resolveCompilationReady in markAsReady to prevent memory retention and redundant double-resolution calls.
…mary and secondary compilation contexts NoopCompilation previously served as a AngularCompilation placeholder to satisfy the compilation requirement on AngularCompilationContext in secondary contexts (such as polyfills and server main code), leading to redundant compiler option extraction and tsconfig loading. AngularCompilationContext is now an abstract base class defining the shared contract. PrimaryCompilationContext encapsulates the active AngularCompilation, manages the lifecycle state, and holds the resolved compiler options. SecondaryCompilationContext omits the compilation entirely, delegates readiness and compiler option resolution to the primary context, and provides no-op lifecycle management. Secondary builds now await primary completion and retrieve compiler options without initializing or invoking a separate compilation.
1e0f46c to
67cfa20
Compare
NoopCompilation previously served as a AngularCompilation placeholder to satisfy the compilation requirement on AngularCompilationContext in secondary contexts (such as polyfills and server main code), leading to redundant compiler option extraction and tsconfig loading.
AngularCompilationContext is now an abstract base class defining the shared contract. PrimaryCompilationContext encapsulates the active AngularCompilation, manages the lifecycle state, and holds the resolved compiler options. SecondaryCompilationContext omits the compilation entirely, delegates readiness and compiler option resolution to the primary context, and provides no-op lifecycle management. Secondary builds now await primary completion and retrieve compiler options without initializing or invoking a separate compilation.