From 49c11c3073ce977a01c84e7848fc070d5de0a652 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Fri, 2 Aug 2024 15:17:01 +0800 Subject: [PATCH] fix: do not terminate dts worker in watch mode, closes #1172, closes #1171 --- src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1c26fd2c3..7da2c6403 100644 --- a/src/index.ts +++ b/src/index.ts @@ -222,6 +222,12 @@ export async function build(_options: Options) { if (options.dts) { await new Promise((resolve, reject) => { const worker = new Worker(path.join(__dirname, './rollup.js')) + + const terminateWorker = () => { + if (options.watch) return + worker.terminate() + } + worker.postMessage({ configName: item?.name, options: { @@ -238,10 +244,10 @@ export async function build(_options: Options) { }) worker.on('message', (data) => { if (data === 'error') { - worker.terminate() + terminateWorker() reject(new Error('error occured in dts build')) } else if (data === 'success') { - worker.terminate() + terminateWorker() resolve() } else { const { type, text } = data