Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: resolve worker-entry extension from import.meta.url

Published 1.0.0 threw "Cannot find module .../dist/worker-entry.ts"
because the worker entry URL was hardcoded as a string literal. tsc's
extension rewriting only handles import specifiers, so .ts leaked into
dist/*.js. Now derived from import.meta.url — src picks .ts, dist picks .js.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+13 -2
+5
.changeset/fix-worker-entry-ext.md
··· 1 + --- 2 + 'moroutine': patch 3 + --- 4 + 5 + Fix `Cannot find module .../dist/worker-entry.ts` when consuming the published build. The worker entry URL was hardcoded to `./worker-entry.ts` as a string literal, so tsc's extension rewriting (which only handles import specifiers) left it unchanged in `dist/*.js`. Now derived from `import.meta.url` so src uses `.ts` and dist uses `.js`.
+4 -1
src/dedicated-runner.ts
··· 1 1 import { Worker } from 'node:worker_threads'; 2 2 import { setupWorker, execute, dispatchStream } from './execute.ts'; 3 3 4 - const workerEntryUrl = new URL('./worker-entry.ts', import.meta.url); 4 + const workerEntryUrl = new URL( 5 + import.meta.url.endsWith('.ts') ? './worker-entry.ts' : './worker-entry.js', 6 + import.meta.url, 7 + ); 5 8 const workers = new Map<string, Worker>(); 6 9 const activeCounts = new Map<Worker, number>(); 7 10
+4 -1
src/worker-pool.ts
··· 7 7 import type { ChannelOptions } from './channel.ts'; 8 8 import type { Task, Balancer, Runner, WorkerHandle, WorkerOptions } from './runner.ts'; 9 9 10 - const workerEntryUrl = new URL('./worker-entry.ts', import.meta.url); 10 + const workerEntryUrl = new URL( 11 + import.meta.url.endsWith('.ts') ? './worker-entry.ts' : './worker-entry.js', 12 + import.meta.url, 13 + ); 11 14 12 15 /** 13 16 * Creates a pool of worker threads with configurable load balancing.