Skip to content

Commit 1b38430

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): disable parallel TS/NG compilation inside WebContainers
When using the `application` or `browser-esbuild` builders, a parallel TS/NG compilation will be used by default via a Node.js Worker. However, when used inside a Web Container, the build will fail to initialize the compilation instance due to what appears to be a defect within Web containers involving the transfer/serialization of a MessageChannel's MessagePort objects. To avoid this problem, the parallel compilation is disabled by default when the build system detects it is being executed from within a Web Container. A parallel compilation can still be forced by using the `NG_BUILD_PARALLEL_TS=1` environment variable. (cherry picked from commit 421c175)
1 parent f87f22d commit 1b38430

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/angular_devkit/build_angular/src/utils/environment-options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ export const allowMinify = debugOptimize.minify;
7878
const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
7979
export const maxWorkers = isPresent(maxWorkersVariable) ? +maxWorkersVariable : 4;
8080

81+
// Default to enabled unless inside a Web Container which currently fails when transferring MessagePort objects
8182
const parallelTsVariable = process.env['NG_BUILD_PARALLEL_TS'];
82-
export const useParallelTs = !isPresent(parallelTsVariable) || !isDisabled(parallelTsVariable);
83+
export const useParallelTs = isPresent(parallelTsVariable)
84+
? !isDisabled(parallelTsVariable)
85+
: !process.versions.webcontainer;
8386

8487
const legacySassVariable = process.env['NG_BUILD_LEGACY_SASS'];
8588
export const useLegacySass: boolean = (() => {

0 commit comments

Comments
 (0)