3 ms·
With Vite you do not have to hack together Hot Module Reloading yourself.
by lyxell 2y ago
With Vite you do not have to hack together Hot Module Reloading yourself.
- Aldipower 2y agoThanks, so I won't use vite. Hot Module Realoading never worked reliable to me.
- lyxell 2y agoI can’t speak for how it works in other frameworks but HMR for React works flawlessly in Vite.
- conradfr 2y agoBecause you did not use Vite.
- homebrewer 2y agoCRA's HMR is a mess that breaks more often than it works, but I haven't had any problems with Vite's HMR after using it for the past three (I think?) years.
- auggierose 2y agoesbuild has live reloading, which works great. No hacking needed. Edit: I don't know how Vite's HMR works, but it wouldn't surprise me if it is just piggybacking on esbuild's live reloading. Anyone here knows if there is a difference between the two?
- yurishimo 2y agoWhen you say "live reloading", does that mean updating the component while maintaining state (HMR) or just triggering some sort of global page refresh? My guess is that Vite relies on underlying tools as much as possible and only ejects when they need to. This is also why they are writing their own version of esbuild/rollup so that more of the dev pipeline can be controlled by Vite.
- auggierose 2y agoWhat I mean by "live reloading" is that when you for example save a TypeScript file, esbuild does an incremental build and your webpage can check for that and reload. There is no state maintained. I think maintaining state would be a very difficult problem to solve correctly. Actually, I think that is impossible, and invites all sorts of heisenbugs, working only for simple cases.
- lyxell 2y agoI’ve used both standalone esbuild as well as Vite for hundreds of hours and HMR works flawlessly in React using Vite, it’s the only reason I use Vite instead of just using esbuild directly. I suggest you to try it out.
- ativzzz 2y agoI've been working with web apps for a long time and have always turned live reloading off whenever I can. My code editor always auto saves changes so i just alt tab to browser and refresh to see changes With live reload, often what happens, especially as projects get larger, is the watcher takes longer to trigger so the live reload is slower than just alt-tabbing, and it sometimes goes off on its own, probably due to multiple quick file changes, which is really annoying I've never enjoyed this feature
- ddoolin 2y agoIt must not be that difficult as I use it every day in my Vite project. To be clear I am no Vite evangelist, but it does maintain existing state when it live reloads modules, it doesn't just refresh the page.