Skip to content

Commit eed60d1

Browse files
alan-agius4clydin
authored andcommitted
refactor(@angular/build): update ensureWorkerPool to do an early exit
The avoid unnecessary logic to be executed for every call to `transformFile`.
1 parent dfeb37f commit eed60d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/angular/build/src/tools/esbuild/javascript-transformer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export class JavaScriptTransformer {
5656
}
5757

5858
#ensureWorkerPool(): WorkerPool {
59+
if (this.#workerPool) {
60+
return this.#workerPool;
61+
}
62+
5963
const workerPoolOptions: WorkerPoolOptions = {
6064
filename: require.resolve('./javascript-transformer-worker'),
6165
maxThreads: this.maxThreads,
@@ -67,7 +71,7 @@ export class JavaScriptTransformer {
6771
workerPoolOptions.execArgv = filteredExecArgv;
6872
}
6973

70-
this.#workerPool ??= new WorkerPool(workerPoolOptions);
74+
this.#workerPool = new WorkerPool(workerPoolOptions);
7175

7276
return this.#workerPool;
7377
}

0 commit comments

Comments
 (0)