@atlaspack/workers 2.12.1-dev.3466 → 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/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"));
@@ -111,16 +110,7 @@ class WorkerFarm extends _events().default {
111
110
  }
112
111
 
113
112
  // $FlowFixMe
114
- if (process.browser) {
115
- if (this.options.workerPath === '@atlaspack/core/worker') {
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
 
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 _buildCache() {
37
- const data = require("@atlaspack/build-cache");
38
- _buildCache = 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
- if (process.browser) {
103
- if (module === '@atlaspack/core/worker') {
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();
@@ -4,22 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- function _nullthrows() {
8
- const data = _interopRequireDefault(require("nullthrows"));
9
- _nullthrows = function () {
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
- var _childState = require("../childState");
15
- var _child = require("../child");
16
- function _buildCache() {
17
- const data = require("@atlaspack/build-cache");
18
- _buildCache = 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) {
@@ -11,22 +11,22 @@ function _worker_threads() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _nullthrows() {
15
- const data = _interopRequireDefault(require("nullthrows"));
16
- _nullthrows = function () {
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
- var _childState = require("../childState");
22
- var _child = require("../child");
23
- function _buildCache() {
24
- const data = require("@atlaspack/build-cache");
25
- _buildCache = 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) {
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _childState = require("../childState");
8
- var _child = require("../child");
9
7
  function _buildCache() {
10
8
  const data = require("@atlaspack/build-cache");
11
9
  _buildCache = function () {
@@ -13,6 +11,8 @@ function _buildCache() {
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/workers",
3
- "version": "2.12.1-dev.3466+9a12fb8bd",
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,21 +17,17 @@
17
17
  "node": ">= 16.0.0"
18
18
  },
19
19
  "dependencies": {
20
- "@atlaspack/diagnostic": "2.12.1-dev.3466+9a12fb8bd",
21
- "@atlaspack/logger": "2.12.1-dev.3466+9a12fb8bd",
22
- "@atlaspack/profiler": "2.12.1-dev.3466+9a12fb8bd",
23
- "@atlaspack/types-internal": "2.12.1-dev.3466+9a12fb8bd",
24
- "@atlaspack/utils": "2.12.1-dev.3466+9a12fb8bd",
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/build-cache": "^2.12.0",
29
- "@atlaspack/core": "^2.12.1-dev.3466+9a12fb8bd"
30
- },
31
28
  "browser": {
32
29
  "./src/process/ProcessWorker.js": false,
33
- "./src/threads/ThreadsWorker.js": false,
34
- "./src/core-worker.js": "./src/core-worker.browser.js"
30
+ "./src/threads/ThreadsWorker.js": false
35
31
  },
36
- "gitHead": "9a12fb8bd1b72e407ed043e20337dc60fbec9cbe"
32
+ "gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
37
33
  }
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';
@@ -104,18 +103,7 @@ export default class WorkerFarm extends EventEmitter {
104
103
  }
105
104
 
106
105
  // $FlowFixMe
107
- if (process.browser) {
108
- if (this.options.workerPath === '@atlaspack/core/worker') {
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;
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/build-cache';
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
- if (process.browser) {
106
- if (module === '@atlaspack/core/worker') {
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
- import {setChild} from '../childState';
12
+
11
13
  import {Child} from '../child';
12
- import {serialize, deserialize} from '@atlaspack/build-cache';
14
+ import {setChild} from '../childState';
13
15
 
14
16
  export default class ProcessChild implements ChildImpl {
15
17
  onMessage: MessageHandler;
@@ -7,7 +7,9 @@ import type {
7
7
  ExitHandler,
8
8
  WorkerMessage,
9
9
  } from '../types';
10
+
10
11
  import childProcess, {type ChildProcess} from 'child_process';
12
+
11
13
  import {serialize, deserialize} from '@atlaspack/build-cache';
12
14
 
13
15
  const WORKER_PATH = require.resolve('./ProcessChild');
@@ -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
- import nullthrows from 'nullthrows';
11
- import {setChild} from '../childState';
12
- import {Child} from '../child';
11
+
13
12
  import {
14
13
  prepareForSerialization,
15
14
  restoreDeserializedObject,
16
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,7 +7,9 @@ import type {
7
7
  ExitHandler,
8
8
  WorkerMessage,
9
9
  } from '../types';
10
+
10
11
  import {Worker} from 'worker_threads';
12
+
11
13
  import {
12
14
  prepareForSerialization,
13
15
  restoreDeserializedObject,
@@ -7,13 +7,15 @@ import type {
7
7
  ExitHandler,
8
8
  WorkerMessage,
9
9
  } from '../types';
10
- import {setChild} from '../childState';
11
- import {Child} from '../child';
10
+
12
11
  import {
13
12
  prepareForSerialization,
14
13
  restoreDeserializedObject,
15
14
  } from '@atlaspack/build-cache';
16
15
 
16
+ import {Child} from '../child';
17
+ import {setChild} from '../childState';
18
+
17
19
  export default class WebChild implements ChildImpl {
18
20
  onMessage: MessageHandler;
19
21
  onExit: ExitHandler;
@@ -7,6 +7,7 @@ import type {
7
7
  ExitHandler,
8
8
  WorkerMessage,
9
9
  } from '../types';
10
+
10
11
  import {
11
12
  prepareForSerialization,
12
13
  restoreDeserializedObject,
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- // $FlowFixMe
4
- module.exports = require('@atlaspack/core/worker');
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- // This is used only in browser builds
4
- module.exports = {};
@@ -1,4 +0,0 @@
1
- // @flow
2
-
3
- // $FlowFixMe
4
- module.exports = require('@atlaspack/core/worker');
@@ -1,2 +0,0 @@
1
- // This is used only in browser builds
2
- module.exports = {};