Skip to content

Commit 43a2631

Browse files
committed
fix(@angular/build): added JavaScriptTransformer close to dispose method
This change allows for awaiting the disposed plugin and added the missing close method of the JavaScript transformer to the onDispose. When the plugin is run multiple times on different projects/bundles without proper closing it will result in a node heap corruption. This allows us to cleanup the build before we start a new one. Closes #31973
1 parent bf990dc commit 43a2631

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,13 @@ export function createCompilerPlugin(
588588
logCumulativeDurations();
589589
});
590590

591-
build.onDispose(() => {
592-
sharedTSCompilationState?.dispose();
593-
void compilation.close?.();
594-
void cacheStore?.close();
595-
});
591+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
592+
build.onDispose(() =>
593+
void Promise.all(
594+
[compilation?.close?.(), cacheStore?.close(), javascriptTransformer.close()].filter(
595+
Boolean,
596+
),
597+
).then(() => sharedTSCompilationState?.dispose());
596598

597599
/**
598600
* Checks if the file has side-effects when `advancedOptimizations` is enabled.

0 commit comments

Comments
 (0)