From: Jérôme Benoit Date: Sun, 2 Apr 2023 13:37:39 +0000 (+0200) Subject: fix: add missing crypto import X-Git-Tag: v2.4.0-0~18 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fc3e65861bc1939ae047ee1e8e91a1ce577035f4;p=poolifier.git fix: add missing crypto import Signed-off-by: Jérôme Benoit --- diff --git a/rollup.config.mjs b/rollup.config.mjs index 44e837d3..017ca1b9 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -34,7 +34,14 @@ export default { ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }) } ], - external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'], + external: [ + 'node:async_hooks', + 'node:cluster', + 'node:crypto', + 'node:events', + 'node:os', + 'node:worker_threads' + ], plugins: [ typescript({ tsconfig: isDevelopmentBuild diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index d63c19ac..363db0e3 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1,3 +1,4 @@ +import crypto from 'node:crypto' import type { MessageValue, PromiseWorkerResponseWrapper diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index 2e89b323..b8a73e4b 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -1,5 +1,5 @@ -import type { ClusterSettings, Worker } from 'cluster' -import cluster from 'cluster' +import type { ClusterSettings, Worker } from 'node:cluster' +import cluster from 'node:cluster' import type { MessageValue } from '../../utility-types' import { AbstractPool } from '../abstract-pool' import type { PoolOptions } from '../pool' diff --git a/src/pools/pool.ts b/src/pools/pool.ts index dbbb5969..8a5e505f 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -1,4 +1,4 @@ -import EventEmitter from 'events' +import EventEmitter from 'node:events' import type { ErrorHandler, ExitHandler, diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index fc9b0695..2813023f 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -1,4 +1,4 @@ -import { cpus } from 'os' +import { cpus } from 'node:os' import type { IPoolInternal } from '../pool-internal' import type { IPoolWorker } from '../pool-worker' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy' diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 13a280b5..a37ccbf7 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -1,4 +1,9 @@ -import { isMainThread, MessageChannel, SHARE_ENV, Worker } from 'worker_threads' +import { + isMainThread, + MessageChannel, + SHARE_ENV, + Worker +} from 'node:worker_threads' import type { Draft, MessageValue } from '../../utility-types' import { AbstractPool } from '../abstract-pool' import type { PoolOptions } from '../pool' diff --git a/src/utility-types.ts b/src/utility-types.ts index fba39012..1a660434 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -1,5 +1,5 @@ -import type { Worker as ClusterWorker } from 'cluster' -import type { MessagePort } from 'worker_threads' +import type { Worker as ClusterWorker } from 'node:cluster' +import type { MessagePort } from 'node:worker_threads' import type { IPoolWorker } from './pools/pool-worker' import type { KillBehavior } from './worker/worker-options' diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index c71ff297..1f42a90b 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -1,6 +1,6 @@ -import { AsyncResource } from 'async_hooks' -import type { Worker } from 'cluster' -import type { MessagePort } from 'worker_threads' +import { AsyncResource } from 'node:async_hooks' +import type { Worker } from 'node:cluster' +import type { MessagePort } from 'node:worker_threads' import type { MessageValue } from '../utility-types' import { EMPTY_FUNCTION } from '../utils' import { diff --git a/src/worker/cluster-worker.ts b/src/worker/cluster-worker.ts index 4f5fbb6b..43e86dd7 100644 --- a/src/worker/cluster-worker.ts +++ b/src/worker/cluster-worker.ts @@ -1,5 +1,5 @@ -import type { Worker } from 'cluster' -import cluster from 'cluster' +import type { Worker } from 'node:cluster' +import cluster from 'node:cluster' import type { MessageValue } from '../utility-types' import { AbstractWorker } from './abstract-worker' import type { WorkerOptions } from './worker-options' diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index a8424fbf..639fd19c 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -1,5 +1,5 @@ -import type { MessagePort } from 'worker_threads' -import { isMainThread, parentPort } from 'worker_threads' +import type { MessagePort } from 'node:worker_threads' +import { isMainThread, parentPort } from 'node:worker_threads' import type { MessageValue } from '../utility-types' import { AbstractWorker } from './abstract-worker' import type { WorkerOptions } from './worker-options'