An esbuild plugin that automatically detects and bundles Node.js Web Workers used in your source code. Version 1.0.8, stable maintenance. Workers are emitted as separate chunks into a workers/ directory with content hashing to avoid name collisions. It relies on the first string literal argument to Worker constructors being a relative path, supporting both ESM (new URL) and CJS (path.join). Differentiators: minimal configuration needed (just add the plugin), works with extended Worker classes, and integrates directly into esbuild's build pipeline. Peer dependency on esbuild. Ships TypeScript types.
npm install esbuild-plugin-node-workerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal setup: import nodeWorker, add to esbuild plugins array, bundle for Node.js.
Ensure your worker path is a string literal, e.g., new Worker(new URL('./worker.mjs', import.meta.url)) or new Worker(path.join(__dirname, 'worker.cjs')).Use a direct path.join with string literals or new URL with string literal path.
If your worker references assume a flat output, adjust paths or use publicPath option.
Update your worker constructor to use a relative path from the output directory, or use the plugin's 'publicPath' option if available.
Use import { nodeWorker } from 'esbuild-plugin-node-worker' or const { nodeWorker } = require('esbuild-plugin-node-worker').Check that your worker instantiation uses a string literal relative path as the first argument, e.g., new Worker(new URL('./worker.js', import.meta.url)).