refactor(@angular/build): introduce AngularCompilationContext to manage compiler lifecycle#33437
refactor(@angular/build): introduce AngularCompilationContext to manage compiler lifecycle#33437clydin wants to merge 1 commit into
Conversation
68f6337 to
f0f31c2
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors the Angular compilation state management by replacing the global SharedTSCompilationState with a localized AngularCompilationContext. This context wraps the AngularCompilation instance and manages its lifecycle, introducing a SecondaryCompilationContext to prevent secondary bundler contexts (such as polyfills or SSR entries) from prematurely disposing of the primary compilation worker. The review feedback highlights two important resource management improvements: wrapping the context setup in a try...catch block in execute-build.ts to prevent resource leaks if an error is thrown during initialization, and catching potential errors during compilation closure in compilation-state.ts to avoid unhandled promise rejections.
f0f31c2 to
474683b
Compare
474683b to
d359f03
Compare
…ge compiler lifecycle Refactors the ambient/global sharedTSCompilationState synchronization singleton into an explicit, orchestrator-instantiated AngularCompilationContext. This context encapsulates the AngularCompilation instance and its ready promise/resolver. The context is instantiated once in executeBuild and passed down to both browser and server compiler plugins, eliminating global state and providing a single cohesive API to manage worker thread lifecycles via context.dispose().
d359f03 to
62a20f4
Compare
Refactors the ambient/global sharedTSCompilationState synchronization singleton into an explicit, orchestrator-instantiated AngularCompilationContext. This context encapsulates the AngularCompilation instance and its ready promise/resolver.
The context is instantiated once in executeBuild and passed down to both browser and server compiler plugins, eliminating global state and providing a single cohesive API to manage worker thread lifecycles via context.dispose().