-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HMR on service worker #5396
Comments
The link if someone interested: w3c/ServiceWorker#1356 |
This comment has been minimized.
This comment has been minimized.
PR #9064 fixed for me the |
The issue is now with react-refresh (I think?)
which is this line |
I am now hitting the issue with
My stack trace is on a random (the first in the dependency graph maybe?) bit of JSX. Has anyone come up with a solution? |
The way to solve this is by adding a side-effectful module that you import before any other modules in your worker. |
I am still having this issue, after trying to migrate from rewired version of react create app. The fix by @cpojer alone did not work, I also had to disable the react plugin... which makes vite painful to use while developing a large project. How can Vite be so popular without having this right?! It seems to be due to random imports (which do not use jsx) which then, for whatever reason, bundles react-refresh with them. No HMR is sort of a dealbreaker on a large project like ours. |
Describe the bug
I'm trying to add HMR to a service worker, I don't know if I can do that, right now it is failing.
The sw code:
The client error:
The failing code:
Reproduction
Here the branch on my repo: https://github.com/userquin/vite-plugin-pwa/tree/feat/add-development-support
pnpm
installed globally required andnode 12+
, I'm testing withnode 15
vianvm
: once cloned and checkoutfeat/add-development-support
executepnpm install && pnpm run build
from root folder.To run the sw example on dev, execute, also from root folder,
pnpm run example:dev:sw
.Open the app in Chrome, it is registered with
type: 'module'
.If you remove the
import.meta.hot
fromexamples/vue-basic-inject-manifest/src/sw.ts
, the service worker will work.The logic for the plugin can be found on
src/index.ts
, search last plugin (name: 'vite-plugin-pwa:dev-sw'
), the internal logic onsrc/dev.ts
: the example onexamples/vue-basic-inject-manifest
.System Info
Used Package Manager
pnpm
Logs
Since it is on client, here the logs on dev tools (see screenshots):
Validations
The text was updated successfully, but these errors were encountered: