From 2bc6e73fbab756d4fa298cd6c686664464fff688 Mon Sep 17 00:00:00 2001 From: renxia Date: Sun, 21 Jan 2024 22:57:02 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20=E9=BB=98=E8=AE=A4=E5=AF=BC=E5=87=BA=20u?= =?UTF-8?q?rl=E3=80=81createChildProcess=20=E7=AD=89=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/index.ts | 1 + src/node/index.ts | 1 + src/node/{ => lib}/worker-threads.ts | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) rename src/node/{ => lib}/worker-threads.ts (91%) diff --git a/src/common/index.ts b/src/common/index.ts index 624296a..ad18073 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -6,4 +6,5 @@ export * from './helper'; export * from './is'; export * from './objects'; export * from './semver'; +export * from './url'; export * from './uuid'; diff --git a/src/node/index.ts b/src/node/index.ts index 8ab353d..5f6c724 100644 --- a/src/node/index.ts +++ b/src/node/index.ts @@ -2,6 +2,7 @@ export * from './lib'; export * from './clearRequireCache'; export * from './clipboard'; export * from './common'; +export * from './createChildProcess'; export * from './createFilePathFilter'; export * from './crypto'; export * from './exec'; diff --git a/src/node/worker-threads.ts b/src/node/lib/worker-threads.ts similarity index 91% rename from src/node/worker-threads.ts rename to src/node/lib/worker-threads.ts index 8b59ef3..cf4ed8e 100644 --- a/src/node/worker-threads.ts +++ b/src/node/lib/worker-threads.ts @@ -10,7 +10,7 @@ */ import { Worker, isMainThread, workerData } from 'node:worker_threads'; // parentPort -import { getLogger } from './get-logger'; +import { getLogger } from '../get-logger'; interface CreateThreadOptions { debug?: boolean; type: string; @@ -61,8 +61,8 @@ if (!isMainThread) { // }; // const resetConfig = { checkOnInit: false, exitOnError: false, mode: 'current' }; - // eslint-disable-next-line @typescript-eslint/no-var-requires - require(config.workerFile)(config); + // eslint-disable-next-line unicorn/prefer-top-level-await + if (config.workerFile) import(config.workerFile).then(f => (f.default || f)(config)); // heartbeat and more... }