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
import*asReactfrom'react';importreactLogofrom'./assets/react.svg';importviteLogofrom'/vite.svg';import'./App.css';importworkerfrom'./worker.ts?worker';functionApp(){const[count,setCount]=React.useState(0);React.useEffect(()=>{constw=newworker();w.postMessage('hey');},[]);return(<><div><ahref="https://vitejs.dev"target="_blank"><imgsrc={viteLogo}className="logo"alt="Vite logo"/></a><ahref="https://react.dev"target="_blank"><imgsrc={reactLogo}className="logo react"alt="React logo"/></a></div><h1>Vite + React</h1><divclassName="card"><buttononClick={()=>setCount((count)=>count+1)}>
count is {count}</button><p>
Edit <code>src/App.tsx</code> and save to test HMR
</p></div><pclassName="read-the-docs">
Click on the Vite and React logos to learn more
</p></>);}exportdefaultApp;
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 vuejs/core instead.
Describe the bug
While running in dev mode and importing a worker that has dependency on a css file. The worker fails to start with
document not defined
I have created a minimal reproduction of the issue on stackblitz
worker.ts
imported in
App.tsx
Reproduction
https://stackblitz.com/edit/vitejs-vite-t1i3lx
Steps to reproduce
Run
npm install
then runnpm run start
Expected:
console log of Hello world
hash
Actual:
Console throws errors and webWorker fails to start.
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: