-
We are currently retrofitting Vite 2 into an old (2016) React project, and while we have gotten Vite to build the project and gotten the development server working, we cannot get HMR to work: any change to any So I am wondering how to debug this setup. What are the main things to look for? I am usually quite good at debugging stuff, but I very new to Vite, so I haven't ventured into the code base yet. Things I think might interfereI have tried looking at the default config created using
Debugging outputEnabling debug output
When I change a file, I jus see a single HMR hit in the new lines in the output:
Config / App Setup / DependenciesI have setup Vite to build our project with this config
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 29 replies
-
OK, I got somewhere on my own using this algo:
After fully restoring
This is the point I am at now. My guess is this |
Beta Was this translation helpful? Give feedback.
-
OK, I figured this one out. It was not exactly the file I thought was the culprit, but something I uncommented at the same time. In fact, it was not a single import, but actually an export. It turns out, that if I add any named export to I made a minimal repo to demonstrate this here: https://github.com/fatso83/break-vite-hmr-with-export |
Beta Was this translation helpful? Give feedback.
-
Did you ever report this as a bug? It seems pretty bad... |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to reopen this discussion? I'm also trying to port over a recent project that uses Are there any common things that might cause HMR to break? |
Beta Was this translation helpful? Give feedback.
-
I ended up figuring out my issue here: preactjs/preset-vite#34. |
Beta Was this translation helpful? Give feedback.
-
Funny enough I had the same error and played around with |
Beta Was this translation helpful? Give feedback.
-
After trying several versions, installing the following version solved my problem "vite": "^2.3.8",
"@vitejs/plugin-react-refresh": "^1.3.4", |
Beta Was this translation helpful? Give feedback.
-
I am currently going through this issue. I've tried almost every fix for this but it still persists. What's even stranger is that it affects only one file: Also, I don't have any export in my App.jsx When I save any changes on the about page, the result in the terminal is [vite] hmr update /src/pages/About/index.jsx
hmr update /src/index.css It doesn't work on /Home/Index.jsx [vite] page reload src/pages/Home/Index.jsx I'll appreciate any help. 😢 |
Beta Was this translation helpful? Give feedback.
-
I also found it useful for debug to look into Network tab into column initiator. |
Beta Was this translation helpful? Give feedback.
OK, I figured this one out. It was not exactly the file I thought was the culprit, but something I uncommented at the same time. In fact, it was not a single import, but actually an export.
It turns out, that if I add any named export to
App.tsx
, all HMR stops working. Just addingexport const foo = 12
breaks it.I made a minimal repo to demonstrate this here: https://github.com/fatso83/break-vite-hmr-with-export
The single line needed to screw up HMR: fatso83/break-vite-hmr-with-export@e3159d5#diff-26ad4b834941d9b19ebf9db8082bd202aaf72ea0ddea85f5a8a0cb3c729cc6f2R7