@atlaspack/workers 2.14.5-dev.69 → 2.14.5-dev.73
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/CHANGELOG.md +9 -0
- package/lib/WorkerFarm.js +2 -16
- package/lib/backend.js +8 -3
- package/lib/bus.js +1 -1
- package/lib/process/ProcessWorker.js +1 -1
- package/lib/threads/ThreadsWorker.js +1 -1
- package/package.json +8 -8
- package/src/WorkerFarm.js +2 -10
- package/src/backend.js +8 -2
- package/src/bus.js +1 -3
- package/src/process/ProcessWorker.js +1 -4
- package/src/threads/ThreadsWorker.js +1 -4
package/CHANGELOG.md
CHANGED
package/lib/WorkerFarm.js
CHANGED
|
@@ -72,13 +72,6 @@ function _logger() {
|
|
|
72
72
|
};
|
|
73
73
|
return data;
|
|
74
74
|
}
|
|
75
|
-
function _core() {
|
|
76
|
-
const data = require("@atlaspack/core");
|
|
77
|
-
_core = function () {
|
|
78
|
-
return data;
|
|
79
|
-
};
|
|
80
|
-
return data;
|
|
81
|
-
}
|
|
82
75
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
83
76
|
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); }
|
|
84
77
|
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; }
|
|
@@ -294,15 +287,8 @@ class WorkerFarm extends _events().default {
|
|
|
294
287
|
var _this$handles$get;
|
|
295
288
|
mod = (0, _nullthrows().default)((_this$handles$get = this.handles.get(handleId)) === null || _this$handles$get === void 0 ? void 0 : _this$handles$get.fn);
|
|
296
289
|
} else if (location) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (location.endsWith('core/workers/bus.js')) {
|
|
300
|
-
mod = bus;
|
|
301
|
-
} else {
|
|
302
|
-
throw new Error('No dynamic require possible: ' + location);
|
|
303
|
-
}
|
|
304
|
-
// $FlowFixMe
|
|
305
|
-
} else if (process.browser) {
|
|
290
|
+
// $FlowFixMe
|
|
291
|
+
if (process.browser) {
|
|
306
292
|
if (location === '@atlaspack/workers/bus') {
|
|
307
293
|
mod = bus;
|
|
308
294
|
} else {
|
package/lib/backend.js
CHANGED
|
@@ -13,9 +13,12 @@ function detectBackend() {
|
|
|
13
13
|
case 'process':
|
|
14
14
|
return process.env.ATLASPACK_WORKER_BACKEND;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
try {
|
|
17
|
+
require('worker_threads');
|
|
18
|
+
return 'threads';
|
|
19
|
+
} catch (err) {
|
|
20
|
+
return 'process';
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
function getWorkerBackend(backend) {
|
|
21
24
|
switch (backend) {
|
|
@@ -23,6 +26,8 @@ function getWorkerBackend(backend) {
|
|
|
23
26
|
return require('./threads/ThreadsWorker').default;
|
|
24
27
|
case 'process':
|
|
25
28
|
return require('./process/ProcessWorker').default;
|
|
29
|
+
case 'web':
|
|
30
|
+
return require('./web/WebWorker').default;
|
|
26
31
|
default:
|
|
27
32
|
throw new Error(`Invalid backend: ${backend}`);
|
|
28
33
|
}
|
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/bus' :
|
|
21
|
+
location: process.browser ? '@atlaspack/workers/bus' : __filename,
|
|
22
22
|
method: 'emit',
|
|
23
23
|
args: [event, ...args]
|
|
24
24
|
}, false);
|
|
@@ -26,7 +26,7 @@ function _buildCache() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
const WORKER_PATH = _path().default.join(
|
|
29
|
+
const WORKER_PATH = _path().default.join(__dirname, './ProcessChild.js');
|
|
30
30
|
class ProcessWorker {
|
|
31
31
|
processQueue = true;
|
|
32
32
|
sendQueue = [];
|
|
@@ -26,7 +26,7 @@ function _buildCache() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
const WORKER_PATH = _path().default.join(
|
|
29
|
+
const WORKER_PATH = _path().default.join(__dirname, './ThreadsChild.js');
|
|
30
30
|
class ThreadsWorker {
|
|
31
31
|
constructor(execArgv, onMessage, onError, onExit) {
|
|
32
32
|
this.execArgv = execArgv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/workers",
|
|
3
|
-
"version": "2.14.5-dev.
|
|
3
|
+
"version": "2.14.5-dev.73+84eec3484",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaspack/build-cache": "2.13.3-dev.
|
|
28
|
-
"@atlaspack/diagnostic": "2.14.1-dev.
|
|
29
|
-
"@atlaspack/logger": "2.14.5-dev.
|
|
30
|
-
"@atlaspack/profiler": "2.14.1-dev.
|
|
31
|
-
"@atlaspack/types-internal": "2.14.1-dev.
|
|
32
|
-
"@atlaspack/utils": "2.14.5-dev.
|
|
27
|
+
"@atlaspack/build-cache": "2.13.3-dev.141+84eec3484",
|
|
28
|
+
"@atlaspack/diagnostic": "2.14.1-dev.141+84eec3484",
|
|
29
|
+
"@atlaspack/logger": "2.14.5-dev.73+84eec3484",
|
|
30
|
+
"@atlaspack/profiler": "2.14.1-dev.141+84eec3484",
|
|
31
|
+
"@atlaspack/types-internal": "2.14.1-dev.141+84eec3484",
|
|
32
|
+
"@atlaspack/utils": "2.14.5-dev.73+84eec3484",
|
|
33
33
|
"nullthrows": "^1.1.1"
|
|
34
34
|
},
|
|
35
35
|
"browser": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"./src/threads/ThreadsWorker.js": false
|
|
38
38
|
},
|
|
39
39
|
"type": "commonjs",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "84eec348413c647de4872f902c4bc8ff54c347f3"
|
|
41
41
|
}
|
package/src/WorkerFarm.js
CHANGED
|
@@ -30,7 +30,6 @@ import {detectBackend} from './backend';
|
|
|
30
30
|
import {SamplingProfiler, Trace} from '@atlaspack/profiler';
|
|
31
31
|
import fs from 'fs';
|
|
32
32
|
import logger from '@atlaspack/logger';
|
|
33
|
-
import {isSuperPackage} from '@atlaspack/core';
|
|
34
33
|
|
|
35
34
|
let referenceId = 1;
|
|
36
35
|
|
|
@@ -344,15 +343,8 @@ export default class WorkerFarm extends EventEmitter {
|
|
|
344
343
|
if (handleId != null) {
|
|
345
344
|
mod = nullthrows(this.handles.get(handleId)?.fn);
|
|
346
345
|
} else if (location) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (location.endsWith('core/workers/bus.js')) {
|
|
350
|
-
mod = (bus: any);
|
|
351
|
-
} else {
|
|
352
|
-
throw new Error('No dynamic require possible: ' + location);
|
|
353
|
-
}
|
|
354
|
-
// $FlowFixMe
|
|
355
|
-
} else if (process.browser) {
|
|
346
|
+
// $FlowFixMe
|
|
347
|
+
if (process.browser) {
|
|
356
348
|
if (location === '@atlaspack/workers/bus') {
|
|
357
349
|
mod = (bus: any);
|
|
358
350
|
} else {
|
package/src/backend.js
CHANGED
|
@@ -11,8 +11,12 @@ export function detectBackend(): BackendType {
|
|
|
11
11
|
return process.env.ATLASPACK_WORKER_BACKEND;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
try {
|
|
15
|
+
require('worker_threads');
|
|
16
|
+
return 'threads';
|
|
17
|
+
} catch (err) {
|
|
18
|
+
return 'process';
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
export function getWorkerBackend(backend: BackendType): Class<WorkerImpl> {
|
|
@@ -21,6 +25,8 @@ export function getWorkerBackend(backend: BackendType): Class<WorkerImpl> {
|
|
|
21
25
|
return require('./threads/ThreadsWorker').default;
|
|
22
26
|
case 'process':
|
|
23
27
|
return require('./process/ProcessWorker').default;
|
|
28
|
+
case 'web':
|
|
29
|
+
return require('./web/WebWorker').default;
|
|
24
30
|
default:
|
|
25
31
|
throw new Error(`Invalid backend: ${backend}`);
|
|
26
32
|
}
|
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/bus'
|
|
13
|
-
: /*#__ATLASPACK_IGNORE__*/ __filename,
|
|
11
|
+
location: process.browser ? '@atlaspack/workers/bus' : __filename,
|
|
14
12
|
method: 'emit',
|
|
15
13
|
args: [event, ...args],
|
|
16
14
|
},
|
|
@@ -13,10 +13,7 @@ import path from 'path';
|
|
|
13
13
|
|
|
14
14
|
import {serialize, deserialize} from '@atlaspack/build-cache';
|
|
15
15
|
|
|
16
|
-
const WORKER_PATH = path.join(
|
|
17
|
-
/*#__ATLASPACK_IGNORE__*/ __dirname,
|
|
18
|
-
'./ProcessChild.js',
|
|
19
|
-
);
|
|
16
|
+
const WORKER_PATH = path.join(__dirname, './ProcessChild.js');
|
|
20
17
|
|
|
21
18
|
export default class ProcessWorker implements WorkerImpl {
|
|
22
19
|
execArgv: Object;
|
|
@@ -16,10 +16,7 @@ import {
|
|
|
16
16
|
restoreDeserializedObject,
|
|
17
17
|
} from '@atlaspack/build-cache';
|
|
18
18
|
|
|
19
|
-
const WORKER_PATH = path.join(
|
|
20
|
-
/*#__ATLASPACK_IGNORE__*/ __dirname,
|
|
21
|
-
'./ThreadsChild.js',
|
|
22
|
-
);
|
|
19
|
+
const WORKER_PATH = path.join(__dirname, './ThreadsChild.js');
|
|
23
20
|
|
|
24
21
|
export default class ThreadsWorker implements WorkerImpl {
|
|
25
22
|
execArgv: Object;
|