Skip to content

Commit 0a2f554

Browse files
shawwndevongovett
authored andcommitted
Use PARCEL_WORKERS environment variable (#589)
* Use PARCEL_WORKERS environment variable * Update WorkerFarm.js
1 parent 25cf217 commit 0a2f554

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ yarn test
3535
[node]: https://nodejs.org/
3636
[yarn]: https://yarnpkg.com/
3737

38+
## Environment variables
39+
40+
You can set `PARCEL_WORKERS` to the number of worker processes to spawn.
41+
42+
`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.
43+
3844
## Financial contributions
3945

4046
We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/parcel).

src/WorkerFarm.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class WorkerFarm extends Farm {
4545
}
4646

4747
await Promise.all(promises);
48-
this.started = true;
48+
if (this.options.maxConcurrentWorkers > 0) {
49+
this.started = true;
50+
}
4951
}
5052

5153
receive(data) {
@@ -97,6 +99,10 @@ for (let key in EventEmitter.prototype) {
9799
}
98100

99101
function getNumWorkers() {
102+
if (process.env.PARCEL_WORKERS) {
103+
return parseInt(process.env.PARCEL_WORKERS, 10);
104+
}
105+
100106
let cores;
101107
try {
102108
cores = require('physical-cpu-count');

0 commit comments

Comments
 (0)