Skip to content

Commit 7b4be00

Browse files
committed
fix(@angular/build): Exclude known --import from execArgv when spawning workers
This change prevents Bazel compilation issues in the ADEV build process.
1 parent 8e2829c commit 7b4be00

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { createHash } from 'node:crypto';
1010
import { readFile } from 'node:fs/promises';
11+
import { IMPORT_EXEC_ARGV } from '../../utils/server-rendering/prerender';
1112
import { WorkerPool } from '../../utils/worker-pool';
1213
import { Cache } from './cache';
1314

@@ -59,7 +60,7 @@ export class JavaScriptTransformer {
5960
filename: require.resolve('./javascript-transformer-worker'),
6061
maxThreads: this.maxThreads,
6162
// Prevent passing `--import` (loader-hooks) from parent to child worker.
62-
execArgv: [],
63+
execArgv: process.execArgv.filter((v) => v !== IMPORT_EXEC_ARGV),
6364
});
6465

6566
return this.#workerPool;

packages/angular/build/src/utils/server-rendering/prerender.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import type { RenderWorkerData } from './render-worker';
2828
type PrerenderOptions = NormalizedApplicationBuildOptions['prerenderOptions'];
2929
type AppShellOptions = NormalizedApplicationBuildOptions['appShellOptions'];
3030

31+
export const IMPORT_EXEC_ARGV =
32+
'--import=' + pathToFileURL(join(__dirname, 'esm-in-memory-loader/register-hooks.js')).href;
33+
3134
/**
3235
* Represents the output of a prerendering process.
3336
*
@@ -195,11 +198,7 @@ async function renderPages(
195198
const output: PrerenderOutput = {};
196199
const errors: string[] = [];
197200

198-
const workerExecArgv = [
199-
'--import',
200-
// Loader cannot be an absolute path on Windows.
201-
pathToFileURL(join(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
202-
];
201+
const workerExecArgv = [IMPORT_EXEC_ARGV];
203202

204203
if (sourcemap) {
205204
workerExecArgv.push('--enable-source-maps');
@@ -301,11 +300,7 @@ async function getAllRoutes(
301300
return { errors: [], serializedRouteTree: routes };
302301
}
303302

304-
const workerExecArgv = [
305-
'--import',
306-
// Loader cannot be an absolute path on Windows.
307-
pathToFileURL(join(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
308-
];
303+
const workerExecArgv = [IMPORT_EXEC_ARGV];
309304

310305
if (sourcemap) {
311306
workerExecArgv.push('--enable-source-maps');

0 commit comments

Comments
 (0)