@atlaspack/workers 2.12.1-dev.3478 → 2.12.1-dev.3502
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.
- package/lib/Handle.js +4 -4
- package/lib/WorkerFarm.js +8 -18
- package/lib/bus.js +1 -1
- package/lib/child.js +10 -20
- package/lib/process/ProcessChild.js +10 -10
- package/lib/process/ProcessWorker.js +6 -13
- package/lib/threads/ThreadsChild.js +10 -10
- package/lib/threads/ThreadsWorker.js +6 -14
- package/lib/web/WebChild.js +7 -7
- package/lib/web/WebWorker.js +5 -5
- package/package.json +9 -12
- package/src/Handle.js +1 -1
- package/src/WorkerFarm.js +3 -15
- package/src/bus.js +1 -3
- package/src/child.js +2 -12
- package/src/process/ProcessChild.js +4 -2
- package/src/process/ProcessWorker.js +4 -3
- package/src/threads/ThreadsChild.js +7 -4
- package/src/threads/ThreadsWorker.js +4 -3
- package/src/web/WebChild.js +5 -3
- package/src/web/WebWorker.js +2 -1
- package/lib/core-worker.browser.js +0 -4
- package/lib/core-worker.js +0 -4
- package/src/core-worker.browser.js +0 -3
- package/src/core-worker.js +0 -2
package/lib/Handle.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data = require("@atlaspack/
|
|
9
|
-
|
|
7
|
+
function _buildCache() {
|
|
8
|
+
const data = require("@atlaspack/build-cache");
|
|
9
|
+
_buildCache = function () {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -42,4 +42,4 @@ class Handle {
|
|
|
42
42
|
// Register the Handle as a serializable class so that it will properly be deserialized
|
|
43
43
|
// by anything that uses WorkerFarm.
|
|
44
44
|
exports.default = Handle;
|
|
45
|
-
(0,
|
|
45
|
+
(0, _buildCache().registerSerializableClass)(`${_package.default.version}:Handle`, Handle);
|
package/lib/WorkerFarm.js
CHANGED
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "Handle", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
exports.default = void 0;
|
|
13
|
-
var coreWorker = _interopRequireWildcard(require("./core-worker"));
|
|
14
13
|
var bus = _interopRequireWildcard(require("./bus"));
|
|
15
14
|
function _assert() {
|
|
16
15
|
const data = _interopRequireDefault(require("assert"));
|
|
@@ -33,9 +32,9 @@ function _events() {
|
|
|
33
32
|
};
|
|
34
33
|
return data;
|
|
35
34
|
}
|
|
36
|
-
function
|
|
37
|
-
const data = require("@atlaspack/
|
|
38
|
-
|
|
35
|
+
function _buildCache() {
|
|
36
|
+
const data = require("@atlaspack/build-cache");
|
|
37
|
+
_buildCache = function () {
|
|
39
38
|
return data;
|
|
40
39
|
};
|
|
41
40
|
return data;
|
|
@@ -111,16 +110,7 @@ class WorkerFarm extends _events().default {
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
// $FlowFixMe
|
|
114
|
-
|
|
115
|
-
if (this.options.workerPath === '@atlaspack/core/src/worker.js') {
|
|
116
|
-
this.localWorker = coreWorker;
|
|
117
|
-
} else {
|
|
118
|
-
throw new Error('No dynamic require possible: ' + this.options.workerPath);
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
// $FlowFixMe this must be dynamic
|
|
122
|
-
this.localWorker = require(this.options.workerPath);
|
|
123
|
-
}
|
|
113
|
+
this.localWorker = require(this.options.workerPath);
|
|
124
114
|
this.localWorkerInit = this.localWorker.childInit != null ? this.localWorker.childInit() : null;
|
|
125
115
|
this.run = this.createHandle('run');
|
|
126
116
|
|
|
@@ -142,7 +132,7 @@ class WorkerFarm extends _events().default {
|
|
|
142
132
|
...request,
|
|
143
133
|
awaitResponse
|
|
144
134
|
});
|
|
145
|
-
return (0,
|
|
135
|
+
return (0, _buildCache().deserialize)((0, _buildCache().serialize)(result));
|
|
146
136
|
},
|
|
147
137
|
createReverseHandle: fn => this.createReverseHandle(fn),
|
|
148
138
|
callChild: (childId, request) => new Promise((resolve, reject) => {
|
|
@@ -198,7 +188,7 @@ class WorkerFarm extends _events().default {
|
|
|
198
188
|
}
|
|
199
189
|
let processedArgs;
|
|
200
190
|
if (!useMainThread) {
|
|
201
|
-
processedArgs = (0,
|
|
191
|
+
processedArgs = (0, _buildCache().restoreDeserializedObject)((0, _buildCache().prepareForSerialization)([...args, false]));
|
|
202
192
|
} else {
|
|
203
193
|
processedArgs = args;
|
|
204
194
|
}
|
|
@@ -299,7 +289,7 @@ class WorkerFarm extends _events().default {
|
|
|
299
289
|
} else if (location) {
|
|
300
290
|
// $FlowFixMe
|
|
301
291
|
if (process.browser) {
|
|
302
|
-
if (location === '@atlaspack/workers/
|
|
292
|
+
if (location === '@atlaspack/workers/bus') {
|
|
303
293
|
mod = bus;
|
|
304
294
|
} else {
|
|
305
295
|
throw new Error('No dynamic require possible: ' + location);
|
|
@@ -440,7 +430,7 @@ class WorkerFarm extends _events().default {
|
|
|
440
430
|
return cached;
|
|
441
431
|
}
|
|
442
432
|
let value = this.sharedReferences.get(ref);
|
|
443
|
-
let buf = (0,
|
|
433
|
+
let buf = (0, _buildCache().serialize)(value).buffer;
|
|
444
434
|
|
|
445
435
|
// If the reference was created with the isCacheable option set to false,
|
|
446
436
|
// serializedSharedReferences will contain `null` as the value.
|
package/lib/bus.js
CHANGED
|
@@ -18,7 +18,7 @@ class Bus extends _events().default {
|
|
|
18
18
|
if (_childState.child) {
|
|
19
19
|
_childState.child.workerApi.callMaster({
|
|
20
20
|
// $FlowFixMe
|
|
21
|
-
location: process.browser ? '@atlaspack/workers/
|
|
21
|
+
location: process.browser ? '@atlaspack/workers/bus' : __filename,
|
|
22
22
|
method: 'emit',
|
|
23
23
|
args: [event, ...args]
|
|
24
24
|
}, false);
|
package/lib/child.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Child = void 0;
|
|
7
|
-
var coreWorker = _interopRequireWildcard(require("./core-worker"));
|
|
8
7
|
function _assert() {
|
|
9
8
|
const data = _interopRequireDefault(require("assert"));
|
|
10
9
|
_assert = function () {
|
|
@@ -19,6 +18,13 @@ function _nullthrows() {
|
|
|
19
18
|
};
|
|
20
19
|
return data;
|
|
21
20
|
}
|
|
21
|
+
function _buildCache() {
|
|
22
|
+
const data = require("@atlaspack/build-cache");
|
|
23
|
+
_buildCache = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
22
28
|
function _logger() {
|
|
23
29
|
const data = _interopRequireWildcard(require("@atlaspack/logger"));
|
|
24
30
|
_logger = function () {
|
|
@@ -33,13 +39,6 @@ function _diagnostic() {
|
|
|
33
39
|
};
|
|
34
40
|
return data;
|
|
35
41
|
}
|
|
36
|
-
function _core() {
|
|
37
|
-
const data = require("@atlaspack/core");
|
|
38
|
-
_core = function () {
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
return data;
|
|
42
|
-
}
|
|
43
42
|
var _bus = _interopRequireDefault(require("./bus"));
|
|
44
43
|
function _profiler() {
|
|
45
44
|
const data = require("@atlaspack/profiler");
|
|
@@ -49,9 +48,9 @@ function _profiler() {
|
|
|
49
48
|
return data;
|
|
50
49
|
}
|
|
51
50
|
var _Handle2 = _interopRequireDefault(require("./Handle"));
|
|
52
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
51
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
54
52
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
53
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
54
|
// The import of './Handle' should really be imported eagerly (with @babel/plugin-transform-modules-commonjs's lazy mode).
|
|
56
55
|
const Handle = _Handle2.default;
|
|
57
56
|
class Child {
|
|
@@ -99,16 +98,7 @@ class Child {
|
|
|
99
98
|
}
|
|
100
99
|
async childInit(module, childId) {
|
|
101
100
|
// $FlowFixMe
|
|
102
|
-
|
|
103
|
-
if (module === '@atlaspack/core/src/worker.js') {
|
|
104
|
-
this.module = coreWorker;
|
|
105
|
-
} else {
|
|
106
|
-
throw new Error('No dynamic require possible: ' + module);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
// $FlowFixMe this must be dynamic
|
|
110
|
-
this.module = require(module);
|
|
111
|
-
}
|
|
101
|
+
this.module = require(module);
|
|
112
102
|
this.childId = childId;
|
|
113
103
|
if (this.module.childInit != null) {
|
|
114
104
|
await this.module.childInit();
|
|
@@ -186,7 +176,7 @@ class Child {
|
|
|
186
176
|
let value = _value instanceof ArrayBuffer ?
|
|
187
177
|
// In the case the value is pre-serialized as a buffer,
|
|
188
178
|
// deserialize it.
|
|
189
|
-
(0,
|
|
179
|
+
(0, _buildCache().deserialize)(Buffer.from(_value)) : _value;
|
|
190
180
|
this.sharedReferences.set(ref, value);
|
|
191
181
|
this.sharedReferencesByValue.set(value, ref);
|
|
192
182
|
result = responseFromContent(null);
|
|
@@ -4,22 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data =
|
|
9
|
-
|
|
7
|
+
function _buildCache() {
|
|
8
|
+
const data = require("@atlaspack/build-cache");
|
|
9
|
+
_buildCache = function () {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
const data = require("@atlaspack/core");
|
|
18
|
-
_core = function () {
|
|
14
|
+
function _nullthrows() {
|
|
15
|
+
const data = _interopRequireDefault(require("nullthrows"));
|
|
16
|
+
_nullthrows = function () {
|
|
19
17
|
return data;
|
|
20
18
|
};
|
|
21
19
|
return data;
|
|
22
20
|
}
|
|
21
|
+
var _child = require("../child");
|
|
22
|
+
var _childState = require("../childState");
|
|
23
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
24
|
class ProcessChild {
|
|
25
25
|
constructor(onMessage, onExit) {
|
|
@@ -34,11 +34,11 @@ class ProcessChild {
|
|
|
34
34
|
if (data === 'die') {
|
|
35
35
|
return this.stop();
|
|
36
36
|
}
|
|
37
|
-
this.onMessage((0,
|
|
37
|
+
this.onMessage((0, _buildCache().deserialize)(Buffer.from(data, 'base64')));
|
|
38
38
|
}
|
|
39
39
|
send(data) {
|
|
40
40
|
let processSend = (0, _nullthrows().default)(process.send).bind(process);
|
|
41
|
-
processSend((0,
|
|
41
|
+
processSend((0, _buildCache().serialize)(data).toString('base64'), err => {
|
|
42
42
|
if (err && err instanceof Error) {
|
|
43
43
|
// $FlowFixMe[prop-missing]
|
|
44
44
|
if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
|
|
@@ -11,22 +11,15 @@ function _child_process() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data =
|
|
16
|
-
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _core() {
|
|
22
|
-
const data = require("@atlaspack/core");
|
|
23
|
-
_core = function () {
|
|
14
|
+
function _buildCache() {
|
|
15
|
+
const data = require("@atlaspack/build-cache");
|
|
16
|
+
_buildCache = function () {
|
|
24
17
|
return data;
|
|
25
18
|
};
|
|
26
19
|
return data;
|
|
27
20
|
}
|
|
28
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
const WORKER_PATH =
|
|
22
|
+
const WORKER_PATH = require.resolve('./ProcessChild');
|
|
30
23
|
class ProcessWorker {
|
|
31
24
|
processQueue = true;
|
|
32
25
|
sendQueue = [];
|
|
@@ -43,7 +36,7 @@ class ProcessWorker {
|
|
|
43
36
|
cwd: process.cwd()
|
|
44
37
|
});
|
|
45
38
|
this.child.on('message', data => {
|
|
46
|
-
this.onMessage((0,
|
|
39
|
+
this.onMessage((0, _buildCache().deserialize)(Buffer.from(data, 'base64')));
|
|
47
40
|
});
|
|
48
41
|
this.child.once('exit', this.onExit);
|
|
49
42
|
this.child.on('error', this.onError);
|
|
@@ -62,7 +55,7 @@ class ProcessWorker {
|
|
|
62
55
|
this.sendQueue.push(data);
|
|
63
56
|
return;
|
|
64
57
|
}
|
|
65
|
-
let result = this.child.send((0,
|
|
58
|
+
let result = this.child.send((0, _buildCache().serialize)(data).toString('base64'), error => {
|
|
66
59
|
if (error && error instanceof Error) {
|
|
67
60
|
// Ignore this, the workerfarm handles child errors
|
|
68
61
|
return;
|
|
@@ -11,22 +11,22 @@ function _worker_threads() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data =
|
|
16
|
-
|
|
14
|
+
function _buildCache() {
|
|
15
|
+
const data = require("@atlaspack/build-cache");
|
|
16
|
+
_buildCache = function () {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
const data = require("@atlaspack/core");
|
|
25
|
-
_core = function () {
|
|
21
|
+
function _nullthrows() {
|
|
22
|
+
const data = _interopRequireDefault(require("nullthrows"));
|
|
23
|
+
_nullthrows = function () {
|
|
26
24
|
return data;
|
|
27
25
|
};
|
|
28
26
|
return data;
|
|
29
27
|
}
|
|
28
|
+
var _child = require("../child");
|
|
29
|
+
var _childState = require("../childState");
|
|
30
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
31
|
class ThreadsChild {
|
|
32
32
|
constructor(onMessage, onExit) {
|
|
@@ -39,10 +39,10 @@ class ThreadsChild {
|
|
|
39
39
|
_worker_threads().parentPort.on('close', this.onExit);
|
|
40
40
|
}
|
|
41
41
|
handleMessage(data) {
|
|
42
|
-
this.onMessage((0,
|
|
42
|
+
this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
|
|
43
43
|
}
|
|
44
44
|
send(data) {
|
|
45
|
-
(0, _nullthrows().default)(_worker_threads().parentPort).postMessage((0,
|
|
45
|
+
(0, _nullthrows().default)(_worker_threads().parentPort).postMessage((0, _buildCache().prepareForSerialization)(data));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
exports.default = ThreadsChild;
|
|
@@ -11,22 +11,14 @@ function _worker_threads() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const data =
|
|
16
|
-
|
|
14
|
+
function _buildCache() {
|
|
15
|
+
const data = require("@atlaspack/build-cache");
|
|
16
|
+
_buildCache = function () {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
const data = require("@atlaspack/core");
|
|
23
|
-
_core = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
const WORKER_PATH = _path().default.join(__dirname, 'ThreadsChild.js');
|
|
21
|
+
const WORKER_PATH = require.resolve('./ThreadsChild');
|
|
30
22
|
class ThreadsWorker {
|
|
31
23
|
constructor(execArgv, onMessage, onError, onExit) {
|
|
32
24
|
this.execArgv = execArgv;
|
|
@@ -52,10 +44,10 @@ class ThreadsWorker {
|
|
|
52
44
|
return Promise.resolve(this.worker.terminate());
|
|
53
45
|
}
|
|
54
46
|
handleMessage(data) {
|
|
55
|
-
this.onMessage((0,
|
|
47
|
+
this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
|
|
56
48
|
}
|
|
57
49
|
send(data) {
|
|
58
|
-
this.worker.postMessage((0,
|
|
50
|
+
this.worker.postMessage((0, _buildCache().prepareForSerialization)(data));
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
exports.default = ThreadsWorker;
|
package/lib/web/WebChild.js
CHANGED
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
const data = require("@atlaspack/core");
|
|
11
|
-
_core = function () {
|
|
7
|
+
function _buildCache() {
|
|
8
|
+
const data = require("@atlaspack/build-cache");
|
|
9
|
+
_buildCache = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
12
|
return data;
|
|
15
13
|
}
|
|
14
|
+
var _child = require("../child");
|
|
15
|
+
var _childState = require("../childState");
|
|
16
16
|
/* eslint-env worker*/
|
|
17
17
|
class WebChild {
|
|
18
18
|
constructor(onMessage, onExit) {
|
|
@@ -34,10 +34,10 @@ class WebChild {
|
|
|
34
34
|
self.postMessage('online');
|
|
35
35
|
}
|
|
36
36
|
handleMessage(data) {
|
|
37
|
-
this.onMessage((0,
|
|
37
|
+
this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
|
|
38
38
|
}
|
|
39
39
|
send(data) {
|
|
40
|
-
self.postMessage((0,
|
|
40
|
+
self.postMessage((0, _buildCache().prepareForSerialization)(data));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
exports.default = WebChild;
|
package/lib/web/WebWorker.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data = require("@atlaspack/
|
|
9
|
-
|
|
7
|
+
function _buildCache() {
|
|
8
|
+
const data = require("@atlaspack/build-cache");
|
|
9
|
+
_buildCache = function () {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -76,10 +76,10 @@ class WebWorker {
|
|
|
76
76
|
return this.stopping;
|
|
77
77
|
}
|
|
78
78
|
handleMessage(data) {
|
|
79
|
-
this.onMessage((0,
|
|
79
|
+
this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
|
|
80
80
|
}
|
|
81
81
|
send(data) {
|
|
82
|
-
this.worker.postMessage((0,
|
|
82
|
+
this.worker.postMessage((0, _buildCache().prepareForSerialization)(data));
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
exports.default = WebWorker;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/workers",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3502+c2daeab5a",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,20 +17,17 @@
|
|
|
17
17
|
"node": ">= 16.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@atlaspack/
|
|
21
|
-
"@atlaspack/
|
|
22
|
-
"@atlaspack/
|
|
23
|
-
"@atlaspack/
|
|
24
|
-
"@atlaspack/
|
|
20
|
+
"@atlaspack/build-cache": "2.12.1-dev.3502+c2daeab5a",
|
|
21
|
+
"@atlaspack/diagnostic": "2.12.1-dev.3502+c2daeab5a",
|
|
22
|
+
"@atlaspack/logger": "2.12.1-dev.3502+c2daeab5a",
|
|
23
|
+
"@atlaspack/profiler": "2.12.1-dev.3502+c2daeab5a",
|
|
24
|
+
"@atlaspack/types-internal": "2.12.1-dev.3502+c2daeab5a",
|
|
25
|
+
"@atlaspack/utils": "2.12.1-dev.3502+c2daeab5a",
|
|
25
26
|
"nullthrows": "^1.1.1"
|
|
26
27
|
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"@atlaspack/core": "^2.12.1-dev.3478+5fd2da535"
|
|
29
|
-
},
|
|
30
28
|
"browser": {
|
|
31
29
|
"./src/process/ProcessWorker.js": false,
|
|
32
|
-
"./src/threads/ThreadsWorker.js": false
|
|
33
|
-
"./src/core-worker.js": "./src/core-worker.browser.js"
|
|
30
|
+
"./src/threads/ThreadsWorker.js": false
|
|
34
31
|
},
|
|
35
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
|
|
36
33
|
}
|
package/src/Handle.js
CHANGED
package/src/WorkerFarm.js
CHANGED
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
} from './types';
|
|
12
12
|
import type {HandleFunction} from './Handle';
|
|
13
13
|
|
|
14
|
-
import * as coreWorker from './core-worker';
|
|
15
14
|
import * as bus from './bus';
|
|
16
15
|
import invariant from 'assert';
|
|
17
16
|
import nullthrows from 'nullthrows';
|
|
@@ -21,7 +20,7 @@ import {
|
|
|
21
20
|
prepareForSerialization,
|
|
22
21
|
restoreDeserializedObject,
|
|
23
22
|
serialize,
|
|
24
|
-
} from '@atlaspack/
|
|
23
|
+
} from '@atlaspack/build-cache';
|
|
25
24
|
import ThrowableDiagnostic, {anyToDiagnostic, md} from '@atlaspack/diagnostic';
|
|
26
25
|
import Worker, {type WorkerCall} from './Worker';
|
|
27
26
|
import cpuCount from './cpuCount';
|
|
@@ -104,18 +103,7 @@ export default class WorkerFarm extends EventEmitter {
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
// $FlowFixMe
|
|
107
|
-
|
|
108
|
-
if (this.options.workerPath === '@atlaspack/core/src/worker.js') {
|
|
109
|
-
this.localWorker = coreWorker;
|
|
110
|
-
} else {
|
|
111
|
-
throw new Error(
|
|
112
|
-
'No dynamic require possible: ' + this.options.workerPath,
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
// $FlowFixMe this must be dynamic
|
|
117
|
-
this.localWorker = require(this.options.workerPath);
|
|
118
|
-
}
|
|
106
|
+
this.localWorker = require(this.options.workerPath);
|
|
119
107
|
|
|
120
108
|
this.localWorkerInit =
|
|
121
109
|
this.localWorker.childInit != null ? this.localWorker.childInit() : null;
|
|
@@ -357,7 +345,7 @@ export default class WorkerFarm extends EventEmitter {
|
|
|
357
345
|
} else if (location) {
|
|
358
346
|
// $FlowFixMe
|
|
359
347
|
if (process.browser) {
|
|
360
|
-
if (location === '@atlaspack/workers/
|
|
348
|
+
if (location === '@atlaspack/workers/bus') {
|
|
361
349
|
mod = (bus: any);
|
|
362
350
|
} else {
|
|
363
351
|
throw new Error('No dynamic require possible: ' + location);
|
package/src/bus.js
CHANGED
|
@@ -8,9 +8,7 @@ class Bus extends EventEmitter {
|
|
|
8
8
|
child.workerApi.callMaster(
|
|
9
9
|
{
|
|
10
10
|
// $FlowFixMe
|
|
11
|
-
location: process.browser
|
|
12
|
-
? '@atlaspack/workers/src/bus.js'
|
|
13
|
-
: __filename,
|
|
11
|
+
location: process.browser ? '@atlaspack/workers/bus' : __filename,
|
|
14
12
|
method: 'emit',
|
|
15
13
|
args: [event, ...args],
|
|
16
14
|
},
|
package/src/child.js
CHANGED
|
@@ -12,12 +12,11 @@ import type {
|
|
|
12
12
|
import type {Async, IDisposable} from '@atlaspack/types-internal';
|
|
13
13
|
import type {SharedReference} from './WorkerFarm';
|
|
14
14
|
|
|
15
|
-
import * as coreWorker from './core-worker';
|
|
16
15
|
import invariant from 'assert';
|
|
17
16
|
import nullthrows from 'nullthrows';
|
|
17
|
+
import {deserialize} from '@atlaspack/build-cache';
|
|
18
18
|
import Logger, {patchConsole, unpatchConsole} from '@atlaspack/logger';
|
|
19
19
|
import ThrowableDiagnostic, {anyToDiagnostic} from '@atlaspack/diagnostic';
|
|
20
|
-
import {deserialize} from '@atlaspack/core';
|
|
21
20
|
import bus from './bus';
|
|
22
21
|
import {SamplingProfiler, tracer} from '@atlaspack/profiler';
|
|
23
22
|
import _Handle from './Handle';
|
|
@@ -102,16 +101,7 @@ export class Child {
|
|
|
102
101
|
|
|
103
102
|
async childInit(module: string, childId: number): Promise<void> {
|
|
104
103
|
// $FlowFixMe
|
|
105
|
-
|
|
106
|
-
if (module === '@atlaspack/core/src/worker.js') {
|
|
107
|
-
this.module = coreWorker;
|
|
108
|
-
} else {
|
|
109
|
-
throw new Error('No dynamic require possible: ' + module);
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
// $FlowFixMe this must be dynamic
|
|
113
|
-
this.module = require(module);
|
|
114
|
-
}
|
|
104
|
+
this.module = require(module);
|
|
115
105
|
this.childId = childId;
|
|
116
106
|
|
|
117
107
|
if (this.module.childInit != null) {
|
|
@@ -6,10 +6,12 @@ import type {
|
|
|
6
6
|
ExitHandler,
|
|
7
7
|
WorkerMessage,
|
|
8
8
|
} from '../types';
|
|
9
|
+
|
|
10
|
+
import {serialize, deserialize} from '@atlaspack/build-cache';
|
|
9
11
|
import nullthrows from 'nullthrows';
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
import {Child} from '../child';
|
|
12
|
-
import {
|
|
14
|
+
import {setChild} from '../childState';
|
|
13
15
|
|
|
14
16
|
export default class ProcessChild implements ChildImpl {
|
|
15
17
|
onMessage: MessageHandler;
|
|
@@ -7,11 +7,12 @@ import type {
|
|
|
7
7
|
ExitHandler,
|
|
8
8
|
WorkerMessage,
|
|
9
9
|
} from '../types';
|
|
10
|
+
|
|
10
11
|
import childProcess, {type ChildProcess} from 'child_process';
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import {serialize, deserialize} from '@atlaspack/core';
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
import {serialize, deserialize} from '@atlaspack/build-cache';
|
|
14
|
+
|
|
15
|
+
const WORKER_PATH = require.resolve('./ProcessChild');
|
|
15
16
|
|
|
16
17
|
export default class ProcessWorker implements WorkerImpl {
|
|
17
18
|
execArgv: Object;
|
|
@@ -6,14 +6,17 @@ import type {
|
|
|
6
6
|
ExitHandler,
|
|
7
7
|
WorkerMessage,
|
|
8
8
|
} from '../types';
|
|
9
|
+
|
|
9
10
|
import {isMainThread, parentPort} from 'worker_threads';
|
|
10
|
-
|
|
11
|
-
import {setChild} from '../childState';
|
|
12
|
-
import {Child} from '../child';
|
|
11
|
+
|
|
13
12
|
import {
|
|
14
13
|
prepareForSerialization,
|
|
15
14
|
restoreDeserializedObject,
|
|
16
|
-
} from '@atlaspack/
|
|
15
|
+
} from '@atlaspack/build-cache';
|
|
16
|
+
import nullthrows from 'nullthrows';
|
|
17
|
+
|
|
18
|
+
import {Child} from '../child';
|
|
19
|
+
import {setChild} from '../childState';
|
|
17
20
|
|
|
18
21
|
export default class ThreadsChild implements ChildImpl {
|
|
19
22
|
onMessage: MessageHandler;
|
|
@@ -7,14 +7,15 @@ import type {
|
|
|
7
7
|
ExitHandler,
|
|
8
8
|
WorkerMessage,
|
|
9
9
|
} from '../types';
|
|
10
|
+
|
|
10
11
|
import {Worker} from 'worker_threads';
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
import {
|
|
13
14
|
prepareForSerialization,
|
|
14
15
|
restoreDeserializedObject,
|
|
15
|
-
} from '@atlaspack/
|
|
16
|
+
} from '@atlaspack/build-cache';
|
|
16
17
|
|
|
17
|
-
const WORKER_PATH =
|
|
18
|
+
const WORKER_PATH = require.resolve('./ThreadsChild');
|
|
18
19
|
|
|
19
20
|
export default class ThreadsWorker implements WorkerImpl {
|
|
20
21
|
execArgv: Object;
|
package/src/web/WebChild.js
CHANGED
|
@@ -7,12 +7,14 @@ import type {
|
|
|
7
7
|
ExitHandler,
|
|
8
8
|
WorkerMessage,
|
|
9
9
|
} from '../types';
|
|
10
|
-
|
|
11
|
-
import {Child} from '../child';
|
|
10
|
+
|
|
12
11
|
import {
|
|
13
12
|
prepareForSerialization,
|
|
14
13
|
restoreDeserializedObject,
|
|
15
|
-
} from '@atlaspack/
|
|
14
|
+
} from '@atlaspack/build-cache';
|
|
15
|
+
|
|
16
|
+
import {Child} from '../child';
|
|
17
|
+
import {setChild} from '../childState';
|
|
16
18
|
|
|
17
19
|
export default class WebChild implements ChildImpl {
|
|
18
20
|
onMessage: MessageHandler;
|
package/src/web/WebWorker.js
CHANGED
|
@@ -7,10 +7,11 @@ import type {
|
|
|
7
7
|
ExitHandler,
|
|
8
8
|
WorkerMessage,
|
|
9
9
|
} from '../types';
|
|
10
|
+
|
|
10
11
|
import {
|
|
11
12
|
prepareForSerialization,
|
|
12
13
|
restoreDeserializedObject,
|
|
13
|
-
} from '@atlaspack/
|
|
14
|
+
} from '@atlaspack/build-cache';
|
|
14
15
|
import {makeDeferredWithPromise} from '@atlaspack/utils';
|
|
15
16
|
|
|
16
17
|
let id = 0;
|
package/lib/core-worker.js
DELETED
package/src/core-worker.js
DELETED