Skip to content

Commit ab17a90

Browse files
committed
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.
1 parent bf990dc commit ab17a90

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,14 @@ 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+
Promise.all(
594+
[compilation?.close?.(), cacheStore?.close(), javascriptTransformer?.close()].filter(
595+
(p): p is Promise<void> => p !== undefined,
596+
),
597+
).then(() => sharedTSCompilationState?.dispose()),
598+
);
596599

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

0 commit comments

Comments
 (0)