Skip to content

Commit 99183e1

Browse files
fix(@angular/build): #31973 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. fix(@angular/build): #31973 - Disable linting warning in onDispose ESbuild will still treat this as a void and this bypass allows for breaking free of the forced fire-and-forget. Functionally this will have no impact on current behavior, it just adds some extra freedom to potentially process and await the Promise. Update packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts Co-authored-by: Alan Agius <alan.agius4@gmail.com>
1 parent bf990dc commit 99183e1

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)