Skip to content

Commit 3019c80

Browse files
committed
perf(@angular/build): dispose builder result context early in non-watch mode
Evaluates and extracts final output results into a list before calling result.dispose() in non-watch mode. This ensures all compiler worker processes (retaining the TypeScript program structures and cache) are terminated and reclaimed before yielding results to the caller for disk writing.
1 parent a583431 commit 3019c80

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/angular/build/src/builders/application/build-action.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ export async function* runEsBuildBuildAction(
148148
// Output the first build results after setting up the watcher to ensure that any code executed
149149
// higher in the iterator call stack will trigger the watcher. This is particularly relevant for
150150
// unit tests which execute the builder and modify the file system programmatically.
151-
yield* emitOutputResults(result, outputOptions);
151+
const outputResults = [...emitOutputResults(result, outputOptions)];
152+
if (!watch) {
153+
await result.dispose();
154+
// Set to true to prevent double-disposal of the result context in the finally block on generator exit
155+
watchLoopStarted = true;
156+
}
157+
yield* outputResults;
152158

153159
// Finish if watch mode is not enabled
154160
if (!watcher) {

0 commit comments

Comments
 (0)