@parcel/workers 2.8.4-nightly.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,66 +4,46 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _worker_threads() {
9
8
  const data = require("worker_threads");
10
-
11
9
  _worker_threads = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _nullthrows() {
19
15
  const data = _interopRequireDefault(require("nullthrows"));
20
-
21
16
  _nullthrows = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  var _childState = require("../childState");
29
-
30
22
  var _child = require("../child");
31
-
32
23
  function _core() {
33
24
  const data = require("@parcel/core");
34
-
35
25
  _core = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
-
44
31
  class ThreadsChild {
45
32
  constructor(onMessage, onExit) {
46
33
  if (_worker_threads().isMainThread || !_worker_threads().parentPort) {
47
34
  throw new Error('Only create ThreadsChild instances in a worker!');
48
35
  }
49
-
50
36
  this.onMessage = onMessage;
51
37
  this.onExit = onExit;
52
-
53
38
  _worker_threads().parentPort.on('message', data => this.handleMessage(data));
54
-
55
39
  _worker_threads().parentPort.on('close', this.onExit);
56
40
  }
57
-
58
41
  handleMessage(data) {
59
42
  this.onMessage((0, _core().restoreDeserializedObject)(data));
60
43
  }
61
-
62
44
  send(data) {
63
45
  (0, _nullthrows().default)(_worker_threads().parentPort).postMessage((0, _core().prepareForSerialization)(data));
64
46
  }
65
-
66
47
  }
67
-
68
48
  exports.default = ThreadsChild;
69
49
  (0, _childState.setChild)(new _child.Child(ThreadsChild));
@@ -4,41 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _worker_threads() {
9
8
  const data = require("worker_threads");
10
-
11
9
  _worker_threads = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _path() {
19
15
  const data = _interopRequireDefault(require("path"));
20
-
21
16
  _path = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _core() {
29
22
  const data = require("@parcel/core");
30
-
31
23
  _core = function () {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
-
40
29
  const WORKER_PATH = _path().default.join(__dirname, 'ThreadsChild.js');
41
-
42
30
  class ThreadsWorker {
43
31
  constructor(execArgv, onMessage, onError, onExit) {
44
32
  this.execArgv = execArgv;
@@ -46,7 +34,6 @@ class ThreadsWorker {
46
34
  this.onError = onError;
47
35
  this.onExit = onExit;
48
36
  }
49
-
50
37
  start() {
51
38
  this.worker = new (_worker_threads().Worker)(WORKER_PATH, {
52
39
  execArgv: this.execArgv,
@@ -59,21 +46,16 @@ class ThreadsWorker {
59
46
  this.worker.on('online', resolve);
60
47
  });
61
48
  }
62
-
63
49
  stop() {
64
50
  // In node 12, this returns a promise, but previously it accepted a callback
65
51
  // TODO: Pass a callback in earlier versions of Node
66
52
  return Promise.resolve(this.worker.terminate());
67
53
  }
68
-
69
54
  handleMessage(data) {
70
55
  this.onMessage((0, _core().restoreDeserializedObject)(data));
71
56
  }
72
-
73
57
  send(data) {
74
58
  this.worker.postMessage((0, _core().prepareForSerialization)(data));
75
59
  }
76
-
77
60
  }
78
-
79
61
  exports.default = ThreadsWorker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/workers",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.1",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,20 +21,20 @@
21
21
  "node": ">= 12.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "@parcel/diagnostic": "2.8.4-nightly.0+7b79c6d",
25
- "@parcel/logger": "2.8.4-nightly.0+7b79c6d",
26
- "@parcel/profiler": "2.8.4-nightly.0+7b79c6d",
27
- "@parcel/types": "2.8.4-nightly.0+7b79c6d",
28
- "@parcel/utils": "2.8.4-nightly.0+7b79c6d",
24
+ "@parcel/diagnostic": "2.9.1",
25
+ "@parcel/logger": "2.9.1",
26
+ "@parcel/profiler": "2.9.1",
27
+ "@parcel/types": "2.9.1",
28
+ "@parcel/utils": "2.9.1",
29
29
  "nullthrows": "^1.1.1"
30
30
  },
31
31
  "peerDependencies": {
32
- "@parcel/core": "2.8.4-nightly.0+7b79c6d"
32
+ "@parcel/core": "^2.9.1"
33
33
  },
34
34
  "browser": {
35
35
  "./src/cpuCount.js": false,
36
36
  "./src/process/ProcessWorker.js": false,
37
37
  "./src/threads/ThreadsWorker.js": false
38
38
  },
39
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
39
+ "gitHead": "5c5dc302b559f0b0d8c57b4d638aac521c879b70"
40
40
  }
package/src/WorkerFarm.js CHANGED
@@ -60,6 +60,8 @@ export type WorkerApi = {|
60
60
 
61
61
  export {Handle};
62
62
 
63
+ const DEFAULT_MAX_CONCURRENT_CALLS: number = 30;
64
+
63
65
  /**
64
66
  * workerPath should always be defined inside farmOptions
65
67
  */
@@ -83,7 +85,9 @@ export default class WorkerFarm extends EventEmitter {
83
85
  super();
84
86
  this.options = {
85
87
  maxConcurrentWorkers: WorkerFarm.getNumWorkers(),
86
- maxConcurrentCallsPerWorker: WorkerFarm.getConcurrentCallsPerWorker(),
88
+ maxConcurrentCallsPerWorker: WorkerFarm.getConcurrentCallsPerWorker(
89
+ farmOptions.shouldTrace ? 1 : DEFAULT_MAX_CONCURRENT_CALLS,
90
+ ),
87
91
  forcedKillTime: 500,
88
92
  warmWorkers: false,
89
93
  useLocalWorker: true, // TODO: setting this to false makes some tests fail, figure out why
@@ -648,8 +652,12 @@ export default class WorkerFarm extends EventEmitter {
648
652
  return child.workerApi;
649
653
  }
650
654
 
651
- static getConcurrentCallsPerWorker(): number {
652
- return parseInt(process.env.PARCEL_MAX_CONCURRENT_CALLS, 10) || 30;
655
+ static getConcurrentCallsPerWorker(
656
+ defaultValue?: number = DEFAULT_MAX_CONCURRENT_CALLS,
657
+ ): number {
658
+ return (
659
+ parseInt(process.env.PARCEL_MAX_CONCURRENT_CALLS, 10) || defaultValue
660
+ );
653
661
  }
654
662
  }
655
663