dev server fails to load workers and wasm files from package dependencies, preview and build work fine #13314
Closed
7 tasks done
Labels
duplicate
This issue or pull request already exists
Describe the bug
I have a package on
npm
which starts a SharedWorker and loads a WASM file. When users install this package vianpm
, vite dev mode is unable to find the worker scripts.If the users do
vite preview
/vite build
, however, everything works as expected.I've created a minimal repro (~10 lines of code) to demonstrate the issue.
Error text (for searchability):
Failed to fetch a worker script
Reproduction
https://github.com/tantaman/vite-worker-repro
Steps to reproduce
git clone [email protected]:tantaman/vite-worker-repro.git
pnpm install
pnpm dev
Open the window, you'll get an error in your console that the worker failed to load.
The worker is loaded from here: https://github.com/tantaman/vite-worker-repro/blob/47637a3d72a3a187c3110a11534c3f1177edf049/src/main.ts#L7-L9
The worker package is here: https://github.com/tantaman/vite-worker-repro/blob/47637a3d72a3a187c3110a11534c3f1177edf049/worker-package/src/index.js#L2-L12
Running
pnpm preview
and everything will work fine.System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: