Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): add NG_BUILD_MAX_WORKERS settim…
Browse files Browse the repository at this point in the history
…gs to control maximum number of workers
  • Loading branch information
alan-agius4 committed May 14, 2021
1 parent 0ebf756 commit 4367c3a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import * as os from 'os';
import * as path from 'path';
import { serialize } from 'v8';
import { BundleActionCache } from './action-cache';
import { maxWorkers } from './environment-options';
import { I18nOptions } from './i18n-options';
import { InlineOptions, ProcessBundleOptions, ProcessBundleResult } from './process-bundle';
import { maxWorkers } from './workers';

let workerFile = require.resolve('./process-bundle');
workerFile =
Expand All @@ -35,7 +35,7 @@ export class BundleActionExecutor {
}

private static executeMethod<O>(worker: JestWorker, method: string, input: unknown): Promise<O> {
return ((worker as unknown) as Record<string, (i: unknown) => Promise<O>>)[method](input);
return (worker as unknown as Record<string, (i: unknown) => Promise<O>>)[method](input);
}

private ensureLarge(): JestWorker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ export const cachingBasePath = (() => {
// Build profiling
const profilingVariable = process.env['NG_BUILD_PROFILING'];
export const profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);

/**
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
* This cause `Error: Call retries were exceeded` errors when trying to use them.
*
* @see https://github.com/nodejs/node/issues/28762
* @see https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
* @see https://ithub.com/angular/angular-cli/issues/16860#issuecomment-588828079
*
*/
const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
export const maxWorkers = isPresent(maxWorkersVariable) ? +maxWorkersVariable : 4;
1 change: 0 additions & 1 deletion packages/angular_devkit/build_angular/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ export * from './normalize-source-maps';
export * from './normalize-optimization';
export * from './normalize-builder-schema';
export * from './url';
export * from './workers';
24 changes: 0 additions & 24 deletions packages/angular_devkit/build_angular/src/utils/workers.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import {
debug,
} from 'webpack';
import { AssetPatternClass } from '../../browser/schema';
import { BuildBrowserFeatures, maxWorkers } from '../../utils';
import { BuildBrowserFeatures } from '../../utils';
import { WebpackConfigOptions } from '../../utils/build-options';
import { findCachePath } from '../../utils/cache-path';
import {
allowMangle,
allowMinify,
cachingDisabled,
maxWorkers,
profilingEnabled,
shouldBeautify,
} from '../../utils/environment-options';
Expand Down

0 comments on commit 4367c3a

Please sign in to comment.