88
99import type { PartialMessage } from 'esbuild' ;
1010import { createRequire } from 'node:module' ;
11- import { MessageChannel , type MessagePort } from 'node:worker_threads' ;
11+ import { MessageChannel } from 'node:worker_threads' ;
1212import { mergeCumulativeDurations } from '../../../utils/profiling' ;
1313import { WorkerPool } from '../../../utils/worker-pool' ;
1414import 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