Skip to content

Commit 39bb07e

Browse files
committed
fixup! perf(@angular/build): avoid web worker channel overhead in library parallel compilation
1 parent 0e2b033 commit 39bb07e

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎packages/angular/build/src/tools/angular/compilation/parallel-compilation.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import type { PartialMessage } from 'esbuild';
1010
import { createRequire } from 'node:module';
11-
import { MessageChannel, type MessagePort } from 'node:worker_threads';
11+
import { MessageChannel } from 'node:worker_threads';
1212
import { mergeCumulativeDurations } from '../../../utils/profiling';
1313
import { WorkerPool } from '../../../utils/worker-pool';
1414
import type { AngularHostOptions } from '../angular-host';
@@ -69,15 +69,13 @@ export class ParallelCompilation extends AngularCompilation {
6969
this.#webWorkerChannel?.port1.close();
7070
this.#webWorkerChannel = undefined;
7171

72-
let webWorkerPort: MessagePort | undefined;
7372
let webWorkerSignal: Int32Array | undefined;
7473
if (buildType !== 'library') {
7574
// The web worker processing is a synchronous operation and uses shared memory combined with
7675
// the Atomics API to block execution here until a response is received.
7776
const webWorkerChannel = new MessageChannel();
7877
this.#webWorkerChannel = webWorkerChannel;
7978
const signal = new Int32Array(new SharedArrayBuffer(4));
80-
webWorkerPort = webWorkerChannel.port2;
8179
webWorkerSignal = signal;
8280
webWorkerChannel.port1.on('message', ({ workerFile, containingFile }) => {
8381
try {
@@ -104,13 +102,13 @@ export class ParallelCompilation extends AngularCompilation {
104102
compilerOptionOverrides,
105103
buildType,
106104
stylesheetPort: stylesheetChannel.port2,
107-
webWorkerPort,
105+
webWorkerPort: this.#webWorkerChannel?.port2,
108106
webWorkerSignal,
109107
},
110108
{
111109
name: 'initialize',
112-
transferList: webWorkerPort
113-
? [stylesheetChannel.port2, webWorkerPort]
110+
transferList: this.#webWorkerChannel
111+
? [stylesheetChannel.port2, this.#webWorkerChannel.port2]
114112
: [stylesheetChannel.port2],
115113
},
116114
);

0 commit comments

Comments
 (0)