Skip to content

Commit 057cc97

Browse files
committed
fix(@ngtools/webpack): use 8gb memory max for type checking
1 parent 58fbe70 commit 057cc97

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/@ngtools/webpack/src/angular_compiler_plugin.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,26 @@ export class AngularCompilerPlugin implements Tapable {
459459
: './type_checker.js';
460460

461461

462+
let hasMemoryFlag = false;
463+
const memoryFlagRegex = /--max-old-space-size/;
464+
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug(?:-brk|-port)/;
465+
462466
const execArgv = process.execArgv.filter((arg) => {
467+
// Check if memory is being set by parent process.
468+
if (memoryFlagRegex.test(arg)) {
469+
hasMemoryFlag = true;
470+
}
471+
463472
// Remove debug args.
464473
// Workaround for https://github.com/nodejs/node/issues/9435
465-
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug(?:-brk|-port)/;
466474
return !debugArgRegex.test(arg);
467475
});
468476

477+
if (!hasMemoryFlag) {
478+
// Force max 8gb ram.
479+
execArgv.push('--max-old-space-size=8192');
480+
}
481+
469482
const forkOptions: ForkOptions = { execArgv };
470483

471484
this._typeCheckerProcess = fork(path.resolve(__dirname, typeCheckerFile), [], forkOptions);

0 commit comments

Comments
 (0)