diff --git a/src/runtime/process-worker.ts b/src/runtime/process-worker.ts index 3b1977f..8830c23 100644 --- a/src/runtime/process-worker.ts +++ b/src/runtime/process-worker.ts @@ -1,6 +1,5 @@ import { ChildProcess, fork } from 'child_process' import { MessagePort, TransferListItem } from 'worker_threads' -import { dirname, resolve } from 'path' import { fileURLToPath } from 'url' import { TinypoolChannel, @@ -21,9 +20,10 @@ export default class ProcessWorker implements TinypoolWorker { waitForExit!: Promise initialize(options: Parameters[0]) { - const __dirname = dirname(fileURLToPath(import.meta.url)) - - this.process = fork(resolve(__dirname, './entry/process.js'), options) + this.process = fork( + fileURLToPath(import.meta.url + '/../entry/process.js'), + options + ) this.threadId = this.process.pid! this.process.on('exit', this.onUnexpectedExit) diff --git a/src/runtime/thread-worker.ts b/src/runtime/thread-worker.ts index 0a8792e..a79da12 100644 --- a/src/runtime/thread-worker.ts +++ b/src/runtime/thread-worker.ts @@ -1,5 +1,4 @@ import { fileURLToPath } from 'url' -import { dirname, resolve } from 'path' import { TransferListItem, Worker } from 'worker_threads' import { TinypoolWorker } from '../common' @@ -10,9 +9,10 @@ export default class ThreadWorker implements TinypoolWorker { threadId!: number initialize(options: Parameters[0]) { - const __dirname = dirname(fileURLToPath(import.meta.url)) - - this.thread = new Worker(resolve(__dirname, './entry/worker.js'), options) + this.thread = new Worker( + fileURLToPath(import.meta.url + '/../entry/worker.js'), + options + ) this.threadId = this.thread.threadId }