@atlaspack/workers 2.12.1-dev.3450 → 2.12.1-dev.3466

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 CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- function _core() {
8
- const data = require("@atlaspack/core");
9
- _core = function () {
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, _core().registerSerializableClass)(`${_package.default.version}:Handle`, Handle);
45
+ (0, _buildCache().registerSerializableClass)(`${_package.default.version}:Handle`, Handle);
package/lib/WorkerFarm.js CHANGED
@@ -33,9 +33,9 @@ function _events() {
33
33
  };
34
34
  return data;
35
35
  }
36
- function _core() {
37
- const data = require("@atlaspack/core");
38
- _core = function () {
36
+ function _buildCache() {
37
+ const data = require("@atlaspack/build-cache");
38
+ _buildCache = function () {
39
39
  return data;
40
40
  };
41
41
  return data;
@@ -112,7 +112,7 @@ class WorkerFarm extends _events().default {
112
112
 
113
113
  // $FlowFixMe
114
114
  if (process.browser) {
115
- if (this.options.workerPath === '@atlaspack/core/src/worker.js') {
115
+ if (this.options.workerPath === '@atlaspack/core/worker') {
116
116
  this.localWorker = coreWorker;
117
117
  } else {
118
118
  throw new Error('No dynamic require possible: ' + this.options.workerPath);
@@ -142,7 +142,7 @@ class WorkerFarm extends _events().default {
142
142
  ...request,
143
143
  awaitResponse
144
144
  });
145
- return (0, _core().deserialize)((0, _core().serialize)(result));
145
+ return (0, _buildCache().deserialize)((0, _buildCache().serialize)(result));
146
146
  },
147
147
  createReverseHandle: fn => this.createReverseHandle(fn),
148
148
  callChild: (childId, request) => new Promise((resolve, reject) => {
@@ -198,7 +198,7 @@ class WorkerFarm extends _events().default {
198
198
  }
199
199
  let processedArgs;
200
200
  if (!useMainThread) {
201
- processedArgs = (0, _core().restoreDeserializedObject)((0, _core().prepareForSerialization)([...args, false]));
201
+ processedArgs = (0, _buildCache().restoreDeserializedObject)((0, _buildCache().prepareForSerialization)([...args, false]));
202
202
  } else {
203
203
  processedArgs = args;
204
204
  }
@@ -299,7 +299,7 @@ class WorkerFarm extends _events().default {
299
299
  } else if (location) {
300
300
  // $FlowFixMe
301
301
  if (process.browser) {
302
- if (location === '@atlaspack/workers/src/bus.js') {
302
+ if (location === '@atlaspack/workers/bus') {
303
303
  mod = bus;
304
304
  } else {
305
305
  throw new Error('No dynamic require possible: ' + location);
@@ -440,7 +440,7 @@ class WorkerFarm extends _events().default {
440
440
  return cached;
441
441
  }
442
442
  let value = this.sharedReferences.get(ref);
443
- let buf = (0, _core().serialize)(value).buffer;
443
+ let buf = (0, _buildCache().serialize)(value).buffer;
444
444
 
445
445
  // If the reference was created with the isCacheable option set to false,
446
446
  // 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/src/bus.js' : __filename,
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
@@ -33,9 +33,9 @@ function _diagnostic() {
33
33
  };
34
34
  return data;
35
35
  }
36
- function _core() {
37
- const data = require("@atlaspack/core");
38
- _core = function () {
36
+ function _buildCache() {
37
+ const data = require("@atlaspack/build-cache");
38
+ _buildCache = function () {
39
39
  return data;
40
40
  };
41
41
  return data;
@@ -100,7 +100,7 @@ class Child {
100
100
  async childInit(module, childId) {
101
101
  // $FlowFixMe
102
102
  if (process.browser) {
103
- if (module === '@atlaspack/core/src/worker.js') {
103
+ if (module === '@atlaspack/core/worker') {
104
104
  this.module = coreWorker;
105
105
  } else {
106
106
  throw new Error('No dynamic require possible: ' + module);
@@ -186,7 +186,7 @@ class Child {
186
186
  let value = _value instanceof ArrayBuffer ?
187
187
  // In the case the value is pre-serialized as a buffer,
188
188
  // deserialize it.
189
- (0, _core().deserialize)(Buffer.from(_value)) : _value;
189
+ (0, _buildCache().deserialize)(Buffer.from(_value)) : _value;
190
190
  this.sharedReferences.set(ref, value);
191
191
  this.sharedReferencesByValue.set(value, ref);
192
192
  result = responseFromContent(null);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
 
3
- // eslint-disable-next-line monorepo/no-internal-import
4
- module.exports = require('@atlaspack/core/src/worker.js');
3
+ // $FlowFixMe
4
+ module.exports = require('@atlaspack/core/worker');
@@ -13,9 +13,9 @@ function _nullthrows() {
13
13
  }
14
14
  var _childState = require("../childState");
15
15
  var _child = require("../child");
16
- function _core() {
17
- const data = require("@atlaspack/core");
18
- _core = function () {
16
+ function _buildCache() {
17
+ const data = require("@atlaspack/build-cache");
18
+ _buildCache = function () {
19
19
  return data;
20
20
  };
21
21
  return data;
@@ -34,11 +34,11 @@ class ProcessChild {
34
34
  if (data === 'die') {
35
35
  return this.stop();
36
36
  }
37
- this.onMessage((0, _core().deserialize)(Buffer.from(data, 'base64')));
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, _core().serialize)(data).toString('base64'), err => {
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 _path() {
15
- const data = _interopRequireDefault(require("path"));
16
- _path = function () {
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 = _path().default.join(__dirname, 'ProcessChild.js');
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, _core().deserialize)(Buffer.from(data, 'base64')));
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, _core().serialize)(data).toString('base64'), error => {
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;
@@ -20,9 +20,9 @@ function _nullthrows() {
20
20
  }
21
21
  var _childState = require("../childState");
22
22
  var _child = require("../child");
23
- function _core() {
24
- const data = require("@atlaspack/core");
25
- _core = function () {
23
+ function _buildCache() {
24
+ const data = require("@atlaspack/build-cache");
25
+ _buildCache = function () {
26
26
  return data;
27
27
  };
28
28
  return data;
@@ -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, _core().restoreDeserializedObject)(data));
42
+ this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
43
43
  }
44
44
  send(data) {
45
- (0, _nullthrows().default)(_worker_threads().parentPort).postMessage((0, _core().prepareForSerialization)(data));
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 _path() {
15
- const data = _interopRequireDefault(require("path"));
16
- _path = 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
- function _core() {
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, _core().restoreDeserializedObject)(data));
47
+ this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
56
48
  }
57
49
  send(data) {
58
- this.worker.postMessage((0, _core().prepareForSerialization)(data));
50
+ this.worker.postMessage((0, _buildCache().prepareForSerialization)(data));
59
51
  }
60
52
  }
61
53
  exports.default = ThreadsWorker;
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _childState = require("../childState");
8
8
  var _child = require("../child");
9
- function _core() {
10
- const data = require("@atlaspack/core");
11
- _core = function () {
9
+ function _buildCache() {
10
+ const data = require("@atlaspack/build-cache");
11
+ _buildCache = function () {
12
12
  return data;
13
13
  };
14
14
  return data;
@@ -34,10 +34,10 @@ class WebChild {
34
34
  self.postMessage('online');
35
35
  }
36
36
  handleMessage(data) {
37
- this.onMessage((0, _core().restoreDeserializedObject)(data));
37
+ this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
38
38
  }
39
39
  send(data) {
40
- self.postMessage((0, _core().prepareForSerialization)(data));
40
+ self.postMessage((0, _buildCache().prepareForSerialization)(data));
41
41
  }
42
42
  }
43
43
  exports.default = WebChild;
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- function _core() {
8
- const data = require("@atlaspack/core");
9
- _core = function () {
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, _core().restoreDeserializedObject)(data));
79
+ this.onMessage((0, _buildCache().restoreDeserializedObject)(data));
80
80
  }
81
81
  send(data) {
82
- this.worker.postMessage((0, _core().prepareForSerialization)(data));
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.3450+58845ef87",
3
+ "version": "2.12.1-dev.3466+9a12fb8bd",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -17,20 +17,21 @@
17
17
  "node": ">= 16.0.0"
18
18
  },
19
19
  "dependencies": {
20
- "@atlaspack/diagnostic": "2.12.1-dev.3450+58845ef87",
21
- "@atlaspack/logger": "2.12.1-dev.3450+58845ef87",
22
- "@atlaspack/profiler": "2.12.1-dev.3450+58845ef87",
23
- "@atlaspack/types-internal": "2.12.1-dev.3450+58845ef87",
24
- "@atlaspack/utils": "2.12.1-dev.3450+58845ef87",
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",
25
25
  "nullthrows": "^1.1.1"
26
26
  },
27
27
  "peerDependencies": {
28
- "@atlaspack/core": "^2.12.1-dev.3450+58845ef87"
28
+ "@atlaspack/build-cache": "^2.12.0",
29
+ "@atlaspack/core": "^2.12.1-dev.3466+9a12fb8bd"
29
30
  },
30
31
  "browser": {
31
32
  "./src/process/ProcessWorker.js": false,
32
33
  "./src/threads/ThreadsWorker.js": false,
33
34
  "./src/core-worker.js": "./src/core-worker.browser.js"
34
35
  },
35
- "gitHead": "58845ef87446fcedb7d7d8876440c64184645cbb"
36
+ "gitHead": "9a12fb8bd1b72e407ed043e20337dc60fbec9cbe"
36
37
  }
package/src/Handle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @flow strict-local
2
- import {registerSerializableClass} from '@atlaspack/core';
2
+ import {registerSerializableClass} from '@atlaspack/build-cache';
3
3
  // $FlowFixMe
4
4
  import packageJson from '../package.json';
5
5
 
package/src/Worker.js CHANGED
@@ -51,7 +51,7 @@ export default class Worker extends EventEmitter {
51
51
  let filteredArgs = [];
52
52
  if (process.execArgv) {
53
53
  filteredArgs = process.execArgv.filter(
54
- v =>
54
+ (v) =>
55
55
  !/^--(debug|inspect|no-opt|max-old-space-size=|max-semi-space-size=|expose-gc)/.test(
56
56
  v,
57
57
  ),
@@ -94,13 +94,13 @@ export default class Worker extends EventEmitter {
94
94
  }
95
95
  }
96
96
 
97
- let onMessage = data => this.receive(data);
98
- let onExit = code => {
97
+ let onMessage = (data) => this.receive(data);
98
+ let onExit = (code) => {
99
99
  this.exitCode = code;
100
100
  this.emit('exit', code);
101
101
  };
102
102
 
103
- let onError = err => {
103
+ let onError = (err) => {
104
104
  this.emit('error', err);
105
105
  };
106
106
 
package/src/WorkerFarm.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  prepareForSerialization,
22
22
  restoreDeserializedObject,
23
23
  serialize,
24
- } from '@atlaspack/core';
24
+ } from '@atlaspack/build-cache';
25
25
  import ThrowableDiagnostic, {anyToDiagnostic, md} from '@atlaspack/diagnostic';
26
26
  import Worker, {type WorkerCall} from './Worker';
27
27
  import cpuCount from './cpuCount';
@@ -105,7 +105,7 @@ export default class WorkerFarm extends EventEmitter {
105
105
 
106
106
  // $FlowFixMe
107
107
  if (process.browser) {
108
- if (this.options.workerPath === '@atlaspack/core/src/worker.js') {
108
+ if (this.options.workerPath === '@atlaspack/core/worker') {
109
109
  this.localWorker = coreWorker;
110
110
  } else {
111
111
  throw new Error(
@@ -266,7 +266,7 @@ export default class WorkerFarm extends EventEmitter {
266
266
 
267
267
  worker.fork(nullthrows(this.options.workerPath));
268
268
 
269
- worker.on('request', data => this.processRequest(data, worker));
269
+ worker.on('request', (data) => this.processRequest(data, worker));
270
270
 
271
271
  worker.on('ready', () => {
272
272
  this.readyWorkers++;
@@ -277,7 +277,7 @@ export default class WorkerFarm extends EventEmitter {
277
277
  });
278
278
  worker.on('response', () => this.processQueue());
279
279
 
280
- worker.on('error', err => this.onError(err, worker));
280
+ worker.on('error', (err) => this.onError(err, worker));
281
281
  worker.once('exit', () => this.stopWorker(worker));
282
282
 
283
283
  this.workers.set(worker.id, worker);
@@ -357,7 +357,7 @@ export default class WorkerFarm extends EventEmitter {
357
357
  } else if (location) {
358
358
  // $FlowFixMe
359
359
  if (process.browser) {
360
- if (location === '@atlaspack/workers/src/bus.js') {
360
+ if (location === '@atlaspack/workers/bus') {
361
361
  mod = (bus: any);
362
362
  } else {
363
363
  throw new Error('No dynamic require possible: ' + location);
@@ -438,7 +438,9 @@ export default class WorkerFarm extends EventEmitter {
438
438
  this.ending = true;
439
439
 
440
440
  await Promise.all(
441
- Array.from(this.workers.values()).map(worker => this.stopWorker(worker)),
441
+ Array.from(this.workers.values()).map((worker) =>
442
+ this.stopWorker(worker),
443
+ ),
442
444
  );
443
445
 
444
446
  for (let handle of this.handles.values()) {
@@ -593,7 +595,7 @@ export default class WorkerFarm extends EventEmitter {
593
595
  }
594
596
 
595
597
  trace.flush();
596
- await new Promise(resolve => {
598
+ await new Promise((resolve) => {
597
599
  stream.once('finish', resolve);
598
600
  });
599
601
 
@@ -629,7 +631,7 @@ export default class WorkerFarm extends EventEmitter {
629
631
  try {
630
632
  let snapshotPaths = await Promise.all(
631
633
  [...this.workers.values()].map(
632
- worker =>
634
+ (worker) =>
633
635
  new Promise((resolve, reject) => {
634
636
  worker.call({
635
637
  method: 'takeHeapSnapshot',
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
@@ -17,7 +17,7 @@ import invariant from 'assert';
17
17
  import nullthrows from 'nullthrows';
18
18
  import Logger, {patchConsole, unpatchConsole} from '@atlaspack/logger';
19
19
  import ThrowableDiagnostic, {anyToDiagnostic} from '@atlaspack/diagnostic';
20
- import {deserialize} from '@atlaspack/core';
20
+ import {deserialize} from '@atlaspack/build-cache';
21
21
  import bus from './bus';
22
22
  import {SamplingProfiler, tracer} from '@atlaspack/profiler';
23
23
  import _Handle from './Handle';
@@ -47,7 +47,7 @@ export class Child {
47
47
 
48
48
  constructor(ChildBackend: Class<ChildImpl>) {
49
49
  this.child = new ChildBackend(
50
- m => {
50
+ (m) => {
51
51
  this.messageListener(m);
52
52
  },
53
53
  () => this.handleEnd(),
@@ -55,11 +55,11 @@ export class Child {
55
55
 
56
56
  // Monitior all logging events inside this child process and forward to
57
57
  // the main process via the bus.
58
- this.loggerDisposable = Logger.onLog(event => {
58
+ this.loggerDisposable = Logger.onLog((event) => {
59
59
  bus.emit('logEvent', event);
60
60
  });
61
61
  // .. and do the same for trace events
62
- this.tracerDisposable = tracer.onTrace(event => {
62
+ this.tracerDisposable = tracer.onTrace((event) => {
63
63
  bus.emit('traceEvent', event);
64
64
  });
65
65
  }
@@ -103,7 +103,7 @@ export class Child {
103
103
  async childInit(module: string, childId: number): Promise<void> {
104
104
  // $FlowFixMe
105
105
  if (process.browser) {
106
- if (module === '@atlaspack/core/src/worker.js') {
106
+ if (module === '@atlaspack/core/worker') {
107
107
  this.module = coreWorker;
108
108
  } else {
109
109
  throw new Error('No dynamic require possible: ' + module);
@@ -1,3 +1,4 @@
1
1
  // @flow
2
- // eslint-disable-next-line monorepo/no-internal-import
3
- module.exports = require('@atlaspack/core/src/worker.js');
2
+
3
+ // $FlowFixMe
4
+ module.exports = require('@atlaspack/core/worker');
package/src/cpuCount.js CHANGED
@@ -29,7 +29,7 @@ export function detectRealCores(): number {
29
29
  } else if (platform === 'win32') {
30
30
  const str = exec('wmic cpu get NumberOfCores').match(/\d+/g);
31
31
  if (str !== null) {
32
- amount = parseInt(str.filter(n => n !== '')[0], 10);
32
+ amount = parseInt(str.filter((n) => n !== '')[0], 10);
33
33
  }
34
34
  }
35
35
 
@@ -9,7 +9,7 @@ import type {
9
9
  import nullthrows from 'nullthrows';
10
10
  import {setChild} from '../childState';
11
11
  import {Child} from '../child';
12
- import {serialize, deserialize} from '@atlaspack/core';
12
+ import {serialize, deserialize} from '@atlaspack/build-cache';
13
13
 
14
14
  export default class ProcessChild implements ChildImpl {
15
15
  onMessage: MessageHandler;
@@ -22,7 +22,7 @@ export default class ProcessChild implements ChildImpl {
22
22
 
23
23
  this.onMessage = onMessage;
24
24
  this.onExit = onExit;
25
- process.on('message', data => this.handleMessage(data));
25
+ process.on('message', (data) => this.handleMessage(data));
26
26
  }
27
27
 
28
28
  handleMessage(data: string): void {
@@ -35,7 +35,7 @@ export default class ProcessChild implements ChildImpl {
35
35
 
36
36
  send(data: WorkerMessage) {
37
37
  let processSend = nullthrows(process.send).bind(process);
38
- processSend(serialize(data).toString('base64'), err => {
38
+ processSend(serialize(data).toString('base64'), (err) => {
39
39
  if (err && err instanceof Error) {
40
40
  // $FlowFixMe[prop-missing]
41
41
  if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
@@ -8,10 +8,9 @@ import type {
8
8
  WorkerMessage,
9
9
  } from '../types';
10
10
  import childProcess, {type ChildProcess} from 'child_process';
11
- import path from 'path';
12
- import {serialize, deserialize} from '@atlaspack/core';
11
+ import {serialize, deserialize} from '@atlaspack/build-cache';
13
12
 
14
- const WORKER_PATH = path.join(__dirname, 'ProcessChild.js');
13
+ const WORKER_PATH = require.resolve('./ProcessChild');
15
14
 
16
15
  export default class ProcessWorker implements WorkerImpl {
17
16
  execArgv: Object;
@@ -55,7 +54,7 @@ export default class ProcessWorker implements WorkerImpl {
55
54
  this.child.send('die');
56
55
 
57
56
  let forceKill = setTimeout(() => this.child.kill('SIGINT'), 500);
58
- await new Promise(resolve => {
57
+ await new Promise((resolve) => {
59
58
  this.child.once('exit', resolve);
60
59
  });
61
60
 
@@ -68,20 +67,23 @@ export default class ProcessWorker implements WorkerImpl {
68
67
  return;
69
68
  }
70
69
 
71
- let result = this.child.send(serialize(data).toString('base64'), error => {
72
- if (error && error instanceof Error) {
73
- // Ignore this, the workerfarm handles child errors
74
- return;
75
- }
76
-
77
- this.processQueue = true;
78
-
79
- if (this.sendQueue.length > 0) {
80
- let queueCopy = this.sendQueue.slice(0);
81
- this.sendQueue = [];
82
- queueCopy.forEach(entry => this.send(entry));
83
- }
84
- });
70
+ let result = this.child.send(
71
+ serialize(data).toString('base64'),
72
+ (error) => {
73
+ if (error && error instanceof Error) {
74
+ // Ignore this, the workerfarm handles child errors
75
+ return;
76
+ }
77
+
78
+ this.processQueue = true;
79
+
80
+ if (this.sendQueue.length > 0) {
81
+ let queueCopy = this.sendQueue.slice(0);
82
+ this.sendQueue = [];
83
+ queueCopy.forEach((entry) => this.send(entry));
84
+ }
85
+ },
86
+ );
85
87
 
86
88
  if (!result || /^win/.test(process.platform)) {
87
89
  // Queue is handling too much messages throttle it
@@ -13,7 +13,7 @@ import {Child} from '../child';
13
13
  import {
14
14
  prepareForSerialization,
15
15
  restoreDeserializedObject,
16
- } from '@atlaspack/core';
16
+ } from '@atlaspack/build-cache';
17
17
 
18
18
  export default class ThreadsChild implements ChildImpl {
19
19
  onMessage: MessageHandler;
@@ -26,7 +26,7 @@ export default class ThreadsChild implements ChildImpl {
26
26
 
27
27
  this.onMessage = onMessage;
28
28
  this.onExit = onExit;
29
- parentPort.on('message', data => this.handleMessage(data));
29
+ parentPort.on('message', (data) => this.handleMessage(data));
30
30
  parentPort.on('close', this.onExit);
31
31
  }
32
32
 
@@ -8,13 +8,12 @@ import type {
8
8
  WorkerMessage,
9
9
  } from '../types';
10
10
  import {Worker} from 'worker_threads';
11
- import path from 'path';
12
11
  import {
13
12
  prepareForSerialization,
14
13
  restoreDeserializedObject,
15
- } from '@atlaspack/core';
14
+ } from '@atlaspack/build-cache';
16
15
 
17
- const WORKER_PATH = path.join(__dirname, 'ThreadsChild.js');
16
+ const WORKER_PATH = require.resolve('./ThreadsChild');
18
17
 
19
18
  export default class ThreadsWorker implements WorkerImpl {
20
19
  execArgv: Object;
@@ -41,11 +40,11 @@ export default class ThreadsWorker implements WorkerImpl {
41
40
  env: process.env,
42
41
  });
43
42
 
44
- this.worker.on('message', data => this.handleMessage(data));
43
+ this.worker.on('message', (data) => this.handleMessage(data));
45
44
  this.worker.on('error', this.onError);
46
45
  this.worker.on('exit', this.onExit);
47
46
 
48
- return new Promise<void>(resolve => {
47
+ return new Promise<void>((resolve) => {
49
48
  this.worker.on('online', resolve);
50
49
  });
51
50
  }
@@ -12,7 +12,7 @@ import {Child} from '../child';
12
12
  import {
13
13
  prepareForSerialization,
14
14
  restoreDeserializedObject,
15
- } from '@atlaspack/core';
15
+ } from '@atlaspack/build-cache';
16
16
 
17
17
  export default class WebChild implements ChildImpl {
18
18
  onMessage: MessageHandler;
@@ -10,7 +10,7 @@ import type {
10
10
  import {
11
11
  prepareForSerialization,
12
12
  restoreDeserializedObject,
13
- } from '@atlaspack/core';
13
+ } from '@atlaspack/build-cache';
14
14
  import {makeDeferredWithPromise} from '@atlaspack/utils';
15
15
 
16
16
  let id = 0;
@@ -44,7 +44,7 @@ describe('WorkerFarm', function () {
44
44
  assert.equal(await workerfarm.run(i), i);
45
45
  }
46
46
 
47
- await new Promise(resolve => workerfarm.once('warmedup', resolve));
47
+ await new Promise((resolve) => workerfarm.once('warmedup', resolve));
48
48
 
49
49
  assert(workerfarm.workers.size > 0, 'Should have spawned workers.');
50
50
  assert(
@@ -134,7 +134,7 @@ describe('WorkerFarm', function () {
134
134
 
135
135
  it('Forwards stdio from the child process and levels event source if shouldPatchConsole is true', async () => {
136
136
  let events = [];
137
- let logDisposable = Logger.onLog(event => events.push(event));
137
+ let logDisposable = Logger.onLog((event) => events.push(event));
138
138
 
139
139
  let workerfarm = new WorkerFarm({
140
140
  warmWorkers: true,
@@ -209,7 +209,7 @@ describe('WorkerFarm', function () {
209
209
 
210
210
  it('Forwards logger events to the main process', async () => {
211
211
  let events = [];
212
- let logDisposable = Logger.onLog(event => events.push(event));
212
+ let logDisposable = Logger.onLog((event) => events.push(event));
213
213
 
214
214
  let workerfarm = new WorkerFarm({
215
215
  warmWorkers: true,