MCPcopy Create free account
hub / github.com/babel/babel / createWorker

Function createWorker

Gulpfile.ts:257–276  ·  view source on GitHub ↗
(useWorker: boolean)

Source from the content-addressed store, hash-verified

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

Callers 1

buildBabelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected