{"id":25428,"library":"esbuild-plugin-webworker","title":"esbuild-plugin-webworker","description":"An ESbuild plugin for handling Web Workers by marking imports with `?worker` query suffix. v0.0.3 (sparse releases). Supports inlining worker code (default) or outputting separate files. Requires ESbuild ≥0.18.0 and Node ≥14.0.0. Differentiators: simple query-based syntax, automatic bundling and minification, TypeScript support. Limited community adoption and maintenance.","status":"active","version":"0.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/simo-an/bundle-plugins","tags":["javascript","esbuild","webworker","esbuild plugin","esbuild plugin webworker","typescript"],"install":[{"cmd":"npm install esbuild-plugin-webworker","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-webworker","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-webworker","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required v0.18.0+","package":"esbuild","optional":false}],"imports":[{"note":"Plugin is ESM only, does not support CommonJS require.","wrong":"const webworker = require('esbuild-plugin-webworker')","symbol":"default","correct":"import webworker from 'esbuild-plugin-webworker'"},{"note":"Worker files must be imported with the `?worker` query suffix to be detected by the plugin.","wrong":"import createWorker from './fib_worker'","symbol":"createWorker","correct":"import createWorker from './fib_worker?worker'"},{"note":"TypeScript types are shipped with the package.","wrong":null,"symbol":"type PluginOptions","correct":"import type { PluginOptions } from 'esbuild-plugin-webworker'"}],"quickstart":{"code":"// build.js\nimport { build } from 'esbuild';\nimport webworker from 'esbuild-plugin-webworker';\n\nbuild({\n  entryPoints: ['src/main.ts'],\n  outfile: 'dist/bundle.js',\n  bundle: true,\n  plugins: [webworker()],\n  format: 'esm',\n}).catch(() => process.exit(1));\n\n// src/main.ts\nimport createWorker from './fib.worker?worker';\n\nconst worker = createWorker();\nconst promise = new Promise<number>((resolve) => {\n  worker.onmessage = (e) => resolve(e.data);\n});\nworker.postMessage(40);\nconsole.log(await promise);\n","lang":"typescript","description":"Sets up esbuild with the webworker plugin, builds a main file that imports a worker script via `?worker`, and runs Fibonacci computation in a worker."},"warnings":[{"fix":"Use import syntax in an ES module context (add 'type':'module' in package.json or use .mjs extension).","message":"Plugin only supports ESM; do not use require() to import the plugin or worker modules.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Update Node to v18 or higher.","message":"Node.js v14 is minimum but v14 is end-of-life; consider upgrading to Node v18+.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Upgrade esbuild to >=0.18.0","message":"Requires esbuild v0.18.0+; older versions will fail with unknown plugin error.","severity":"breaking","affected_versions":"<0.18.0"},{"fix":"Set inline:false and specify an out directory to generate separate worker files.","message":"Default inline:true may cause large bundles if worker code is substantial; memory usage can be high.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install esbuild@latest` to update to a compatible version.","cause":"Installed esbuild version is too low (<0.18.0).","error":"Error: The plugin \"esbuild-plugin-webworker\" is not compatible with the current version of esbuild. Required esbuild >= 0.18.0"},{"fix":"Set `\"type\": \"module\"` in your package.json or rename the file to .mjs.","cause":"Using import syntax in a CommonJS file without enabling ESM.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Switch to ESM import or use dynamic import: `import('esbuild-plugin-webworker').then(m => m.default())`.","cause":"Default import used with CommonJS require; plugin exports ES module default.","error":"TypeError: webworker is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}