@parcel/workers 2.0.0-nightly.121 → 2.0.0-nightly.1211

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.
@@ -25,7 +25,7 @@ export default class ProcessChild implements ChildImpl {
25
25
  process.on('message', data => this.handleMessage(data));
26
26
  }
27
27
 
28
- handleMessage(data: string) {
28
+ handleMessage(data: string): void {
29
29
  if (data === 'die') {
30
30
  return this.stop();
31
31
  }
@@ -37,6 +37,7 @@ export default class ProcessChild implements ChildImpl {
37
37
  let processSend = nullthrows(process.send).bind(process);
38
38
  processSend(serialize(data).toString('base64'), err => {
39
39
  if (err && err instanceof Error) {
40
+ // $FlowFixMe[prop-missing]
40
41
  if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
41
42
  // IPC connection closed
42
43
  // no need to keep the worker running if it can't send or receive data
@@ -34,7 +34,7 @@ export default class ProcessWorker implements WorkerImpl {
34
34
  this.onExit = onExit;
35
35
  }
36
36
 
37
- start() {
37
+ start(): Promise<void> {
38
38
  this.child = childProcess.fork(WORKER_PATH, process.argv, {
39
39
  execArgv: this.execArgv,
40
40
  env: process.env,
@@ -32,7 +32,7 @@ export default class ThreadsWorker implements WorkerImpl {
32
32
  this.onExit = onExit;
33
33
  }
34
34
 
35
- start() {
35
+ start(): Promise<void> {
36
36
  this.worker = new Worker(WORKER_PATH, {
37
37
  execArgv: this.execArgv,
38
38
  env: process.env,
@@ -47,7 +47,7 @@ export default class ThreadsWorker implements WorkerImpl {
47
47
  });
48
48
  }
49
49
 
50
- stop() {
50
+ stop(): Promise<void> {
51
51
  // In node 12, this returns a promise, but previously it accepted a callback
52
52
  // TODO: Pass a callback in earlier versions of Node
53
53
  return Promise.resolve(this.worker.terminate());
@@ -3,7 +3,7 @@ import os from 'os';
3
3
 
4
4
  import getCores, {detectRealCores} from '../src/cpuCount';
5
5
 
6
- describe('cpuCount', function() {
6
+ describe('cpuCount', function () {
7
7
  it('Should be able to detect real cpu count', () => {
8
8
  // Windows not supported as getting the cpu count takes a couple seconds...
9
9
  if (os.platform() === 'win32') return;
@@ -1,4 +1,4 @@
1
- const WorkerFarm = require('../../../').default;
1
+ const WorkerFarm = require('../../../src/WorkerFarm').default;
2
2
 
3
3
  function run() {
4
4
  if (WorkerFarm.isWorker()) {
@@ -1,4 +1,4 @@
1
- const WorkerFarm = require('../../../').default;
1
+ const WorkerFarm = require('../../../src/WorkerFarm').default;
2
2
  const Logger = require('@parcel/logger').default;
3
3
 
4
4
  function run() {
@@ -1,5 +1,5 @@
1
- function run(_, handle) {
2
- return handle();
1
+ function run(workerApi, handle) {
2
+ return workerApi.runHandle(handle, []);
3
3
  }
4
4
 
5
5
  exports.run = run;
@@ -1,8 +1,8 @@
1
1
  import Logger from '@parcel/logger';
2
2
  import assert from 'assert';
3
- import WorkerFarm from '../';
3
+ import WorkerFarm from '../src';
4
4
 
5
- describe('WorkerFarm', function() {
5
+ describe('WorkerFarm', function () {
6
6
  this.timeout(30000);
7
7
 
8
8
  it('Should start up workers', async () => {
@@ -132,7 +132,7 @@ describe('WorkerFarm', function() {
132
132
  await workerfarm.end();
133
133
  });
134
134
 
135
- it('Forwards stdio from the child process and levels event source if patchConsole is true', async () => {
135
+ it('Forwards stdio from the child process and levels event source if shouldPatchConsole is true', async () => {
136
136
  let events = [];
137
137
  let logDisposable = Logger.onLog(event => events.push(event));
138
138
 
@@ -140,7 +140,7 @@ describe('WorkerFarm', function() {
140
140
  warmWorkers: true,
141
141
  useLocalWorker: false,
142
142
  workerPath: require.resolve('./integration/workerfarm/console.js'),
143
- patchConsole: true,
143
+ shouldPatchConsole: true,
144
144
  });
145
145
 
146
146
  await workerfarm.run();
@@ -291,7 +291,7 @@ describe('WorkerFarm', function() {
291
291
  assert.equal(result, 'Shared reference does not exist');
292
292
  });
293
293
 
294
- it('should resolve shared references in workers', async () => {
294
+ it('Should resolve shared references in workers', async () => {
295
295
  let workerfarm = new WorkerFarm({
296
296
  warmWorkers: true,
297
297
  useLocalWorker: false,