Skip to content

Commit 7841041

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 b9681c0 commit 7841041

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ 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+
}
155+
yield* outputResults;
152156

153157
// Finish if watch mode is not enabled
154158
if (!watcher) {

0 commit comments

Comments
 (0)