fix: use factory method to create worker executor
This commit is contained in:
@ -16,7 +16,7 @@ import presetReact from '@babel/preset-react';
|
|||||||
import protect from 'loop-protect';
|
import protect from 'loop-protect';
|
||||||
|
|
||||||
import * as vinyl from '../utils/polyvinyl.js';
|
import * as vinyl from '../utils/polyvinyl.js';
|
||||||
import WorkerExecutor from '../utils/worker-executor';
|
import createWorker from '../utils/worker-executor';
|
||||||
|
|
||||||
const protectTimeout = 100;
|
const protectTimeout = 100;
|
||||||
Babel.registerPlugin('loopProtection', protect(protectTimeout));
|
Babel.registerPlugin('loopProtection', protect(protectTimeout));
|
||||||
@ -91,7 +91,7 @@ export const babelTransformer = cond([
|
|||||||
[stubTrue, identity]
|
[stubTrue, identity]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const sassWorker = new WorkerExecutor('sass-compile');
|
const sassWorker = createWorker('sass-compile');
|
||||||
async function transformSASS(element) {
|
async function transformSASS(element) {
|
||||||
const styleTags = element.querySelectorAll('style[type="text/sass"]');
|
const styleTags = element.querySelectorAll('style[type="text/sass"]');
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
@ -27,14 +27,14 @@ import {
|
|||||||
|
|
||||||
import { challengeTypes } from '../../../../utils/challengeTypes';
|
import { challengeTypes } from '../../../../utils/challengeTypes';
|
||||||
|
|
||||||
import WorkerExecutor from '../utils/worker-executor';
|
import createWorker from '../utils/worker-executor';
|
||||||
import {
|
import {
|
||||||
createMainFramer,
|
createMainFramer,
|
||||||
createTestFramer,
|
createTestFramer,
|
||||||
runTestInTestFrame
|
runTestInTestFrame
|
||||||
} from '../utils/frame.js';
|
} from '../utils/frame.js';
|
||||||
|
|
||||||
const testWorker = new WorkerExecutor('test-evaluator');
|
const testWorker = createWorker('test-evaluator');
|
||||||
const testTimeout = 5000;
|
const testTimeout = 5000;
|
||||||
|
|
||||||
function* ExecuteChallengeSaga() {
|
function* ExecuteChallengeSaga() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { homeLocation } from '../../../../config/env.json';
|
import { homeLocation } from '../../../../config/env.json';
|
||||||
|
|
||||||
export default class WorkerExecutor {
|
class WorkerExecutor {
|
||||||
constructor(workerName) {
|
constructor(workerName) {
|
||||||
this.workerName = workerName;
|
this.workerName = workerName;
|
||||||
this.worker = null;
|
this.worker = null;
|
||||||
@ -71,3 +71,7 @@ export default class WorkerExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function createWorkerExecutor(workerName) {
|
||||||
|
return new WorkerExecutor(workerName);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user