Registry / devops / esbuild-plugin-inline-worker

esbuild-plugin-inline-worker

JSON →
library0.1.1jsnpmunverified

An esbuild plugin that inlines Web Worker code directly into the bundle, eliminating the need for a separate worker file. Version 0.1.1 is stable, with no recent updates. It supports importing .worker.js/.ts/.jsx/.tsx files to get a Worker constructor, bundling the worker code with a separate esbuild build. Unlike worker-loader for webpack, this plugin fully inlines the worker, making it ideal for libraries where worker file management is cumbersome. It ships TypeScript definitions and allows custom esbuild configuration for the worker build.

devops
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM-only. No default export in CommonJS; must use dynamic import or build tool that handles ESM.

import inlineWorkerPlugin from 'esbuild-plugin-inline-worker'

Worker is a default export from the .worker file, treated as a class constructor.

import Worker from './example.worker.js'

The argument is directly the esbuild build options object; not nested under extraConfig.

inlineWorkerPlugin({ format: 'iife' })

Shows how to use the plugin in an esbuild build and import a .worker.ts file to create an inlined Web Worker.

import { build } from 'esbuild'; import inlineWorkerPlugin from 'esbuild-plugin-inline-worker'; await build({ entryPoints: ['src/index.ts'], bundle: true, outfile: 'dist/bundle.js', plugins: [inlineWorkerPlugin()], }); // src/index.ts import Worker from './worker.worker.ts'; const worker = Worker(); worker.onmessage = (e) => { console.log(e.data); }; worker.postMessage('hello');
Debug
Known footguns
gotchaWorker files must use the .worker.js/.worker.ts (etc.) suffix; regular .js files will not be treated as workers.
gotchaThe worker code is bundled in a separate esbuild build, so global variables defined in main bundle are not available in worker unless explicitly passed.
breakingESM-only: CommonJS require() will not work for this plugin. Users on older Node.js or CJS projects may encounter errors.
deprecatedThe plugin's configuration object cannot override entryPoints, outfile, or outdir; those are deleted internally.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
12 hits · last 30 days
gptbot
4
ahrefsbot
3
claudebot
3
script
1
Resources