vite icon indicating copy to clipboard operation
vite copied to clipboard

build --watch doesnt build workers

Open Fuzzyma opened this issue 2 years ago • 1 comments

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

Fuzzyma avatar Jan 22 '23 21:01 Fuzzyma

maybe related: #8172

sapphi-red avatar Jan 24 '23 16:01 sapphi-red