Skip to content

Commit

Permalink
fix: do not terminate dts worker in watch mode, closes #1172, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Aug 2, 2024
1 parent e9ee083 commit 49c11c3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ export async function build(_options: Options) {
if (options.dts) {
await new Promise<void>((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: {
Expand All @@ -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
Expand Down

0 comments on commit 49c11c3

Please sign in to comment.