Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: configurable parallelism of jest and build:multi #1025

Merged
merged 3 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/guides/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ This can be done by setting the environment variable `NODE_OPTIONS=--max_old_spa
[Debug Angular apps in production without revealing source maps](https://medium.com/angular-in-depth/debug-angular-apps-in-production-without-revealing-source-maps-ab4a235edd85)

- If you also generate the source maps for production builds, you can load them in the browser development tools and use them for debugging production setups.

## Parallelism

The parallelism of `npm run test` and `npm run build:multi` can be customized with environment variables.

The environment variable `JEST_MAX_WORKERS` is deferred to [`maxWorkers`](https://jestjs.io/docs/configuration#maxworkers-number--string) of `jest`.

The environment variable `PWA_BUILD_MAX_WORKERS` is deferred to [`--max-parallel`](https://github.com/mysticatea/npm-run-all/blob/master/docs/npm-run-all.md#npm-run-all-command) of `npm-run-all`.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
},
preset: 'jest-preset-angular',
testRunner: 'jest-jasmine2',
maxWorkers: '75%', // keep some cpu for moving the mouse
maxWorkers: process.env.JEST_MAX_WORKERS || '75%', // keep some cpu for moving the mouse
roots: ['src', 'projects'],
setupFilesAfterEnv: ['<rootDir>/src/setupJest.ts'],
transformIgnorePatterns: [`node_modules/(?!${esModules.join('|')})`],
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-multi-pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (processArgs.includes('server') || !processArgs.includes('client'))
)
);

const cores = Math.round(require('os').cpus().length / 3) || 1;
const cores = +process.env.PWA_BUILD_MAX_WORKERS || Math.round(require('os').cpus().length / 3) || 1;
const parallel = cores === 1 ? [] : ['--max-parallel', cores, '--parallel'];
if (parallel) {
console.log(`Using ${cores} cores for multi compile.`);
Expand Down