{"id":31574606,"url":"https://github.com/aheissenberger/vite-plugin-node-worker","last_synced_at":"2026-01-20T17:36:00.060Z","repository":{"id":311691536,"uuid":"1044608062","full_name":"aheissenberger/vite-plugin-node-worker","owner":"aheissenberger","description":"Vite plugin for Node.js worker threads. Supports DEV and BUILD modes.","archived":false,"fork":false,"pushed_at":"2025-08-28T00:32:58.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-04T07:36:14.672Z","etag":null,"topics":["nodejs","plugin","vitejs","worker-threads"],"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/aheissenberger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-26T00:24:41.000Z","updated_at":"2025-08-28T00:33:01.000Z","dependencies_parsed_at":"2025-08-26T02:41:00.583Z","dependency_job_id":"583d9f98-85e6-4fc8-a67c-04828b173e17","html_url":"https://github.com/aheissenberger/vite-plugin-node-worker","commit_stats":null,"previous_names":["aheissenberger/vite-plugin-node-worker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aheissenberger/vite-plugin-node-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fvite-plugin-node-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fvite-plugin-node-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fvite-plugin-node-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fvite-plugin-node-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aheissenberger","download_url":"https://codeload.github.com/aheissenberger/vite-plugin-node-worker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aheissenberger%2Fvite-plugin-node-worker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278478409,"owners_count":25993665,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["nodejs","plugin","vitejs","worker-threads"],"created_at":"2025-10-05T16:08:41.999Z","updated_at":"2025-10-05T16:08:42.915Z","avatar_url":"https://github.com/aheissenberger.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-node-worker\n\nA plugin to serve and build ViteJS projects with [Node Worker Threads](https://nodejs.org/api/worker_threads.html).\n\n## Features\n\n* Supports DEV and BUILD mode\n* Transforms Workers writen in TypeScript.\n* respects alias configuration in vite.config.ts\n\n## Install \u0026 Configuration\n\n### Install dependencies\n\n```bash\nnpm install vite-plugin-node-worker\n```\n\n### Setup ViteJS\n\n```ts\n// ./vite.config.ts\nimport { defineConfig } from \"vite\";\nimport workerPlugin from \"vite-plugin-node-worker\";\nexport default defineConfig({\n  plugins: [workerPlugin()],\n  worker: {\n    plugins: () =\u003e [workerPlugin()],\n  },\n});\n```\n\n**Note:** `worker: {}` applys the transformation in ViteJS Dev Mode.\n\n### Import Worker\n\nThe path to the worker file needs to be suffixed with `?nodeWorker` or `?modulePath`.\n\n**Wrapper Mode**\n\n```ts\nimport ApiWorker from \"./api-worker.ts?nodeWorker\";\nconst apiW = ApiWorker({ workerData: { hello: \"world\" } });\napi.postMessage(\"MSG\")\n```\n\ntransforms `import ApiWorker from \"./api-worker.ts?nodeWorker\";` to:\n\n```js\nimport { Worker } from 'node:worker_threads';\nexport default function (options) { return new Worker(new URL(${assetRefId}, import.meta.url), options) }\n```\n\n\n**Path Export**\n\n```ts\nimport ApiWorkerPath from \"./api-worker.ts?modulePath\";\nimport { Worker } from \"node:worker_threads\"\nconst apiW = new Worker(workerPath, { workerData: { hello: \"world\" } });\napi.postMessage(\"MSG\")\n```\n\ntransforms `import ApiWorkerPath from \"./api-worker.ts?modulePath\";` to:\n\n```js\nexport default ${assetRefId}\n```\n\n## Troubleshooting\n\n**Clean Cache:**\n\n```bash\nrm -rf node_modules/.vite-plugin-node-worker\n```\n\n**Activate Debug**\n\n```bash\nVNW_DEBUG=1 npm run dev\n```\n\n**Worker Naming Clash**\n\nBy default vite will place the worker in the root of the build target directory.\nIf two worker have the same name they will be overwriten. Use different names or config vite to add a file hash to worker files.\n\n## Related Projects\n\nThis plugin is based on code from:\n\n- https://www.npmjs.com/package/@fetsorn/vite-node-worker\n- https://github.com/alex8088/electron-vite/blob/master/src/plugins/worker.ts\n\nThe difference is the support of the ViteJS DEV mode.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheissenberger%2Fvite-plugin-node-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faheissenberger%2Fvite-plugin-node-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faheissenberger%2Fvite-plugin-node-worker/lists"}