{"id":17000153,"url":"https://github.com/mitschabaude/esbuild-plugin-inline-worker","last_synced_at":"2025-03-17T09:30:46.526Z","repository":{"id":42450488,"uuid":"392769022","full_name":"mitschabaude/esbuild-plugin-inline-worker","owner":"mitschabaude","description":"Esbuild loader for inline Web Workers","archived":false,"fork":false,"pushed_at":"2022-04-05T13:20:48.000Z","size":12,"stargazers_count":38,"open_issues_count":4,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-27T21:50:30.858Z","etag":null,"topics":["esbuild","esbuild-plugin","multithreading","web-worker"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitschabaude.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-04T17:07:44.000Z","updated_at":"2025-01-06T13:03:06.000Z","dependencies_parsed_at":"2022-08-25T14:41:39.682Z","dependency_job_id":null,"html_url":"https://github.com/mitschabaude/esbuild-plugin-inline-worker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitschabaude%2Fesbuild-plugin-inline-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitschabaude%2Fesbuild-plugin-inline-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitschabaude%2Fesbuild-plugin-inline-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitschabaude%2Fesbuild-plugin-inline-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitschabaude","download_url":"https://codeload.github.com/mitschabaude/esbuild-plugin-inline-worker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858891,"owners_count":20359257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esbuild","esbuild-plugin","multithreading","web-worker"],"created_at":"2024-10-14T04:11:13.845Z","updated_at":"2025-03-17T09:30:46.198Z","avatar_url":"https://github.com/mitschabaude.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esbuild-plugin-inline-worker\n\nThis is a plugin for [esbuild](https://esbuild.github.io) which allows you to import `.worker.js` files to get the constructor for a Web Worker, similar to [worker-loader](https://github.com/webpack-contrib/worker-loader) for Webpack.\n\n```sh\nyarn add esbuild-plugin-inline-worker\n```\n\nExample:\n\n```js\n// example.worker.js\npostMessage('hello from worker!');\n```\n\n```js\n// example.js\nimport Worker from './example.worker.js';\nlet worker = Worker();\nworker.onmessage = ({data}) =\u003e console.log(data);\n```\n\nIn this example, `worker` will be an instance of [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker).\n\nConveniently, you don't have to take care of having the worker's JavaScript file in the right location on your server. Instead, the JS code for the worker is inlined to the bundle produced by esbuild. This makes this plugin perfect for JS library authors who want to use workers for performance optimization, where the need for a separate worker file is awkward.\n\nThe inlined worker code will be created with a separate call to esbuild. That means your worker code can import libraries and use TypeScript or JSX!\nSupported file extensions for the worker are `.worker.js`, `.worker.ts`, `.worker.jsx`, `.worker.tsx`.\n\n## Usage\n\n```js\nimport {build} from 'esbuild';\nimport inlineWorkerPlugin from 'esbuild-plugin-inline-worker';\n\nbuild({\n  /* ... */\n  plugins: [inlineWorkerPlugin()],\n});\n```\n\n## Build configuration\n\nOptionally, you can pass a configuration object which has the same interface as esbuild's [build API](https://esbuild.github.io/api/#build-api), which determines how the worker code is bundled:\n\n```js\ninlineWorkerPlugin(extraConfig);\n```\n\nThis is how your custom config is used internally:\n\n```js\nif (extraConfig) {\n  delete extraConfig.entryPoints;\n  delete extraConfig.outfile;\n  delete extraConfig.outdir;\n}\n\nawait esbuild.build({\n  entryPoints: [workerPath],\n  bundle: true,\n  minify: true,\n  outfile: bundlePath,\n  target: 'es2017',\n  format: 'esm',\n  ...extraConfig, // \u003c-- your config can override almost everything\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitschabaude%2Fesbuild-plugin-inline-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitschabaude%2Fesbuild-plugin-inline-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitschabaude%2Fesbuild-plugin-inline-worker/lists"}