@@ -66,28 +66,23 @@ export class ParallelCompilation extends AngularCompilation {
6666 ) ;
6767
6868 this . #webWorkerChannel?. port1 . close ( ) ;
69- this . #webWorkerChannel = undefined ;
7069
71- let webWorkerSignal : Int32Array | undefined ;
72- if ( buildType !== 'library' ) {
73- // The web worker processing is a synchronous operation and uses shared memory combined with
74- // the Atomics API to block execution here until a response is received.
75- const webWorkerChannel = new MessageChannel ( ) ;
76- this . #webWorkerChannel = webWorkerChannel ;
77- const signal = new Int32Array ( new SharedArrayBuffer ( 4 ) ) ;
78- webWorkerSignal = signal ;
79- webWorkerChannel . port1 . on ( 'message' , ( { workerFile, containingFile } ) => {
80- try {
81- const workerCodeFile = hostOptions . processWebWorker ( workerFile , containingFile ) ;
82- webWorkerChannel . port1 . postMessage ( { workerCodeFile } ) ;
83- } catch ( error ) {
84- webWorkerChannel . port1 . postMessage ( { error } ) ;
85- } finally {
86- Atomics . store ( signal , 0 , 1 ) ;
87- Atomics . notify ( signal , 0 ) ;
88- }
89- } ) ;
90- }
70+ // The web worker processing is a synchronous operation and uses shared memory combined with
71+ // the Atomics API to block execution here until a response is received.
72+ const webWorkerChannel = new MessageChannel ( ) ;
73+ this . #webWorkerChannel = webWorkerChannel ;
74+ const webWorkerSignal = new Int32Array ( new SharedArrayBuffer ( 4 ) ) ;
75+ webWorkerChannel . port1 . on ( 'message' , ( { workerFile, containingFile } ) => {
76+ try {
77+ const workerCodeFile = hostOptions . processWebWorker ( workerFile , containingFile ) ;
78+ webWorkerChannel . port1 . postMessage ( { workerCodeFile } ) ;
79+ } catch ( error ) {
80+ webWorkerChannel . port1 . postMessage ( { error } ) ;
81+ } finally {
82+ Atomics . store ( webWorkerSignal , 0 , 1 ) ;
83+ Atomics . notify ( webWorkerSignal , 0 ) ;
84+ }
85+ } ) ;
9186
9287 let success = false ;
9388 try {
@@ -100,14 +95,12 @@ export class ParallelCompilation extends AngularCompilation {
10095 browserOnlyBuild : this . browserOnlyBuild ,
10196 compilerOptionOverrides,
10297 stylesheetPort : stylesheetChannel . port2 ,
103- webWorkerPort : this . # webWorkerChannel? .port2 ,
98+ webWorkerPort : webWorkerChannel . port2 ,
10499 webWorkerSignal,
105100 } ,
106101 {
107102 name : 'initialize' ,
108- transferList : this . #webWorkerChannel
109- ? [ stylesheetChannel . port2 , this . #webWorkerChannel. port2 ]
110- : [ stylesheetChannel . port2 ] ,
103+ transferList : [ stylesheetChannel . port2 , webWorkerChannel . port2 ] ,
111104 } ,
112105 ) ;
113106 success = true ;
0 commit comments