Skip to content

refactor(@angular/build): eliminate NoopCompilation and introduce primary and secondary compilation contexts - #33978

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:refactor/eliminate-noop-compilation
Open

refactor(@angular/build): eliminate NoopCompilation and introduce primary and secondary compilation contexts#33978
clydin wants to merge 1 commit into
angular:mainfrom
clydin:refactor/eliminate-noop-compilation

Conversation

@clydin

@clydin clydin commented Aug 31, 2026

Copy link
Copy Markdown
Member

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.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 31, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/angular/build/src/tools/esbuild/angular/compilation-state.ts Outdated
Comment thread packages/angular/build/src/tools/esbuild/angular/compilation-state.ts Outdated
@clydin
clydin force-pushed the refactor/eliminate-noop-compilation branch 2 times, most recently from c4158b4 to 1e0f46c Compare August 31, 2026 17:02
@clydin

clydin commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@clydin
clydin force-pushed the refactor/eliminate-noop-compilation branch from 1e0f46c to 67cfa20 Compare August 31, 2026 17:06
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 31, 2026
@clydin
clydin requested a review from alan-agius4 August 31, 2026 17:25
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

2 participants