Skip to content

Commit 799f332

Browse files
committed
refactor(@angular/build): hoist blob instantiation in i18n inliner batch loop
Instantiate codeBlob and mapBlob once per file outside the batch loop instead of re-creating new Blob instances on each batch slice. Blobs are immutable, read-only binary handles and can be safely shared across multiple worker batch tasks concurrently.
1 parent 4182b96 commit 799f332

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/angular/build/src/tools/esbuild/i18n-inliner.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ export class I18nInliner {
459459
const codeFile = this.#localizeFiles.get(filename);
460460
assert(codeFile !== undefined, 'Localize file must exist: ' + filename);
461461
const mapFile = this.#localizeFiles.get(filename + '.map');
462+
const codeBlob = new Blob([codeFile.contents]);
463+
const mapBlob = mapFile ? new Blob([mapFile.contents]) : undefined;
462464

463465
const ephemeral = isLastWindow && entries.length <= localesPerBatch;
464466
for (let i = 0; i < entries.length; i += localesPerBatch) {
@@ -467,8 +469,8 @@ export class I18nInliner {
467469
const batchResult = (await this.#workerPool.run(
468470
{
469471
filename,
470-
code: new Blob([codeFile.contents]),
471-
map: mapFile ? new Blob([mapFile.contents]) : undefined,
472+
code: codeBlob,
473+
map: mapBlob,
472474
locales: new Map(batchEntries.map((e) => [e.locale, e.translation])),
473475
ephemeral,
474476
activeLocales,

0 commit comments

Comments
 (0)