From ccf09712acafa4b835fa0cb3f2087a17425832fc Mon Sep 17 00:00:00 2001 From: ryo Date: Wed, 11 Mar 2020 12:42:44 +0900 Subject: [PATCH] chore(gatsby): Convert utils/worker/pool to typescript (#22150) --- packages/gatsby/src/commands/build.js | 2 +- packages/gatsby/src/commands/develop.ts | 2 +- packages/gatsby/src/utils/worker/pool.js | 14 -------------- packages/gatsby/src/utils/worker/pool.ts | 10 ++++++++++ 4 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 packages/gatsby/src/utils/worker/pool.js create mode 100644 packages/gatsby/src/utils/worker/pool.ts diff --git a/packages/gatsby/src/commands/build.js b/packages/gatsby/src/commands/build.js index 15493987fcde1..86dc0e84f96fb 100644 --- a/packages/gatsby/src/commands/build.js +++ b/packages/gatsby/src/commands/build.js @@ -15,7 +15,7 @@ const telemetry = require(`gatsby-telemetry`) const { store, emitter, readState } = require(`../redux`) const queryUtil = require(`../query`) import * as appDataUtil from "../utils/app-data" -const WorkerPool = require(`../utils/worker/pool`) +import * as WorkerPool from "../utils/worker/pool" const { structureWebpackErrors } = require(`../utils/webpack-error-utils`) const { waitUntilAllJobsComplete: waitUntilAllJobsV2Complete, diff --git a/packages/gatsby/src/commands/develop.ts b/packages/gatsby/src/commands/develop.ts index 22532a9608b7e..1e0953854df5a 100644 --- a/packages/gatsby/src/commands/develop.ts +++ b/packages/gatsby/src/commands/develop.ts @@ -27,7 +27,7 @@ import chalk from "chalk" import address from "address" import cors from "cors" import telemetry from "gatsby-telemetry" -import WorkerPool from "../utils/worker/pool" +import * as WorkerPool from "../utils/worker/pool" import http from "http" import https from "https" diff --git a/packages/gatsby/src/utils/worker/pool.js b/packages/gatsby/src/utils/worker/pool.js deleted file mode 100644 index 160ea6cfc0c19..0000000000000 --- a/packages/gatsby/src/utils/worker/pool.js +++ /dev/null @@ -1,14 +0,0 @@ -const Worker = require(`jest-worker`).default -const { cpuCoreCount } = require(`gatsby-core-utils`) - -const create = () => - new Worker(require.resolve(`./child`), { - numWorkers: cpuCoreCount(), - forkOptions: { - silent: false, - }, - }) - -module.exports = { - create, -} diff --git a/packages/gatsby/src/utils/worker/pool.ts b/packages/gatsby/src/utils/worker/pool.ts new file mode 100644 index 0000000000000..c322e5a0bf3bf --- /dev/null +++ b/packages/gatsby/src/utils/worker/pool.ts @@ -0,0 +1,10 @@ +import Worker from "jest-worker" +import { cpuCoreCount } from "gatsby-core-utils" + +export const create = (): Worker => + new Worker(require.resolve(`./child`), { + numWorkers: cpuCoreCount(), + forkOptions: { + silent: false, + }, + })