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

Use PARCEL_WORKERS environment variable #589

Merged
merged 2 commits into from
Jan 20, 2018
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
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ yarn test
[node]: https://nodejs.org/
[yarn]: https://yarnpkg.com/

## Environment variables

You can set `PARCEL_WORKERS` to the number of worker processes to spawn.

`PARCEL_WORKERS=0` is handy for debugging, because that will cause all code to be run on the main thread. This allows you to place breakpoints in Asset code, for example.

## Financial contributions

We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/parcel).
Expand Down
8 changes: 7 additions & 1 deletion src/WorkerFarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class WorkerFarm extends Farm {
}

await Promise.all(promises);
this.started = true;
if (this.options.maxConcurrentWorkers > 0) {
this.started = true;
}
}

receive(data) {
Expand Down Expand Up @@ -97,6 +99,10 @@ for (let key in EventEmitter.prototype) {
}

function getNumWorkers() {
if (process.env.PARCEL_WORKERS) {
return parseInt(process.env.PARCEL_WORKERS, 10);
}

let cores;
try {
cores = require('physical-cpu-count');
Expand Down