Hacker News new | ask | show | jobs
by yurishimo 610 days ago
When 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.

1 comments

What 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.
I’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.
I'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

It 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.