vite-plugin-react-swc
vite-plugin-react-swc copied to clipboard
fix: React in WebWorker window is undefined
Previously the HMR code would use window as the global scope which is undefined in webworkers.
This change uses some code lifted from @vitejs/plugin-react to check if the context is in a webworker before doing trying to use window.
HMR is not currently possible in vite (https://github.com/vitejs/vite-plugin-react/issues/152) so nothing happens when the worker file is edited.