Skip to content

Commit

Permalink
fix: remove worker_threads require
Browse files Browse the repository at this point in the history
  • Loading branch information
sauravhiremath committed Jul 21, 2020
1 parent 0167abc commit c562f9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/jest-worker/src/Farm.ts
Expand Up @@ -85,9 +85,9 @@ export default class Farm {
const onEnd: OnEnd = (error: Error | null, result: unknown) => {
customMessageListeners.clear();
if (error) {
return reject(error);
reject(error);

This comment has been minimized.

Copy link
@sunlaiman
} else {
return resolve(result);
resolve(result);
}
};

Expand Down
5 changes: 1 addition & 4 deletions packages/jest-worker/src/workers/messageParent.ts
Expand Up @@ -8,15 +8,12 @@
import {isMainThread, parentPort} from 'worker_threads';
import {PARENT_MESSAGE_CUSTOM} from '../types';

const isWorkerThread = !isMainThread && parentPort;

const messageParent = (
message: unknown,
parentProcess: NodeJS.Process = process,
): void => {
try {
if (isWorkerThread) {
const {parentPort} = require('worker_threads');
if (!isMainThread && parentPort) {
parentPort.postMessage([PARENT_MESSAGE_CUSTOM, message]);
} else if (typeof parentProcess.send === 'function') {
parentProcess.send([PARENT_MESSAGE_CUSTOM, message]);
Expand Down

1 comment on commit c562f9f

@sunlaiman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#10227 #

Please sign in to comment.