Skip to content

Commit

Permalink
Use PARCEL_WORKERS environment variable (#589)
Browse files Browse the repository at this point in the history
* Use PARCEL_WORKERS environment variable

* Update WorkerFarm.js
  • Loading branch information
shawwn authored and devongovett committed Jan 20, 2018
1 parent 25cf217 commit 0a2f554
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 0a2f554

Please sign in to comment.