MCPcopy
hub / github.com/babel/babel / createWorker

Function createWorker

Gulpfile.ts:255–274  ·  view source on GitHub ↗
(useWorker: boolean)

Source from the content-addressed store, hash-verified

253}
254
255function createWorker(useWorker: boolean): any {
256 const numWorkers = Math.ceil(Math.max(cpus().length, 1) / 2) - 1;
257 if (
258 numWorkers === 0 ||
259 !useWorker ||
260 // For some reason, on CircleCI the workers hang indefinitely.
261 process.env.CIRCLECI
262 ) {
263 return import("./babel-worker.ts");
264 }
265 const worker = new JestWorker(new URL("./babel-worker.ts", import.meta.url), {
266 enableWorkerThreads: true,
267 numWorkers,
268 exposedMethods: ["transform"],
269 });
270
271 worker.getStdout().pipe(process.stdout);
272 worker.getStderr().pipe(process.stderr);
273 return worker;
274}
275
276async function buildBabel(useWorker: boolean, ignore: PackageInfo[] = []) {
277 const worker = await createWorker(useWorker);

Callers 1

buildBabelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…