vite
vite copied to clipboard
build --watch doesnt build workers
Describe the bug
Running build in watch mode will not create the asset file for the worker.
The call to the worker is transpiled to return new Worker("/") which is wrong as well because the path is missing.
Since this call only loads the index.html, the script errors out with Uncaught SyntaxError: Unexpected token '<' (at (index):1:1)
Reproduction
https://stackblitz.com/edit/vitejs-vite-yz9aab?file=main.js
Steps to reproduce
open the link, run npm run build -- --watch and in a new terminal window npm run preview
If you now change the main file to output a different console message, the worker asset file gets deleted and refreshing the preview window will throw the above error
System Info
System:
OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (16) x64 AMD Ryzen 7 PRO 6850HS with Radeon Graphics
Memory: 22.68 GB / 24.52 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 19.4.0 - /usr/bin/node
Yarn: 3.2.2 - /usr/bin/yarn
npm: 9.2.0 - /usr/bin/npm
npmPackages:
vite: ^4.0.0 => 4.0.4
Used Package Manager
yarn
Logs
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] 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 vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
maybe related: #8172