You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working on a library project that uses web workers - a main worker to move computations off the main thread, which can spawn multiple sub workers to distribute computations and run them in parallel. In order to import the workers I used the corresponding syntax (import MyWorker from "./worker?worker";) Vite provides. But when building the library with vite build there is no file for the sub worker emitted.
As you will see in the reproduction section, the same applies for an application as well, so it's not an issue with the library mode.
The application works fine during development but when running vite build the following files are emitted:
The application uses the standard vanilla-ts template and is extended by the main-worker.ts and sub-worker.ts files.
So you can run npm run dev, which should work as expected. And you can run npm run build & npm run serve to preview the production code, which should not work.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
Small update: I've updated Vite in the reproduction repo to 2.8.0-beta.1 because I thought this issue might be related to #6191 and fixed by #6351.
But the issue remains. While import statements like import "./test"; or import something from "./test"; are bundled correctly when used in a worker, a sub worker module as in this case is still not emitted during build.
Describe the bug
I was working on a library project that uses web workers - a main worker to move computations off the main thread, which can spawn multiple sub workers to distribute computations and run them in parallel. In order to import the workers I used the corresponding syntax (
import MyWorker from "./worker?worker";
) Vite provides. But when building the library withvite build
there is no file for the sub worker emitted.As you will see in the reproduction section, the same applies for an application as well, so it's not an issue with the library mode.
The application works fine during development but when running
vite build
the following files are emitted:But in the
main-worker.71484cf4.js
file the sub worker file is referenced properly:So, apparently the sub worker file is included as build artifact but it is just not emitted to the assets directory.
Thanks for your help!
Reproduction
https://github.com/XR4Z0R/vite-nested-workers
The application uses the standard
vanilla-ts
template and is extended by themain-worker.ts
andsub-worker.ts
files.So you can run
npm run dev
, which should work as expected. And you can runnpm run build
&npm run serve
to preview the production code, which should not work.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: