@parcel/workers 2.8.4-nightly.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/Handle.js +4 -15
- package/lib/Worker.js +4 -42
- package/lib/WorkerFarm.js +22 -126
- package/lib/backend.js +0 -6
- package/lib/bus.js +0 -10
- package/lib/child.js +15 -68
- package/lib/childState.js +0 -1
- package/lib/cpuCount.js +2 -20
- package/lib/index.js +2 -29
- package/lib/process/ProcessChild.js +0 -17
- package/lib/process/ProcessWorker.js +0 -22
- package/lib/threads/ThreadsChild.js +0 -20
- package/lib/threads/ThreadsWorker.js +0 -18
- package/package.json +8 -8
- package/src/WorkerFarm.js +11 -3
@@ -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.
|
3
|
+
"version": "2.9.0",
|
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.
|
25
|
-
"@parcel/logger": "2.
|
26
|
-
"@parcel/profiler": "2.
|
27
|
-
"@parcel/types": "2.
|
28
|
-
"@parcel/utils": "2.
|
24
|
+
"@parcel/diagnostic": "2.9.0",
|
25
|
+
"@parcel/logger": "2.9.0",
|
26
|
+
"@parcel/profiler": "2.9.0",
|
27
|
+
"@parcel/types": "2.9.0",
|
28
|
+
"@parcel/utils": "2.9.0",
|
29
29
|
"nullthrows": "^1.1.1"
|
30
30
|
},
|
31
31
|
"peerDependencies": {
|
32
|
-
"@parcel/core": "2.
|
32
|
+
"@parcel/core": "^2.9.0"
|
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": "
|
39
|
+
"gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
|
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(
|
652
|
-
|
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
|
|