fastify/fastify-vite

Server HMR

bskimball opened this issue ยท 2 comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

๐Ÿš€ Feature Proposal

Are there plans for server HMR?

Motivation

I could use nodemon, but it restarts the vite server every change. It would be nice to be able to get hmr on the server as well.

Example

yarn dev would hmr on client and server

Yeah, it's tricky to figure out the mechanics for this, i.e., knowing when to restart Fastify fully or just redefine a route handler, or just redefine a route component through Vite's dev server. I'm working on this in preparation for Fastify DX! We already have a prototype that delivers enhanced experience but it needs more work before a public beta is viable.

For now I'd say use fastify-cli or nodemon (or minimon!) with a rule to ignore client/ file changes. This way you get to restart Fastify automatically when you do server.js changes, and let Vite handle the client ones.

The automation Fastify DX will allow is also automatically resetting the route handling when you export special functions from components, like in the getServerSideProps experiment.

Thanks, I went with minimon. I'll close this issue and look forward to fastify dx