Skip to content
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

Adjust Vite HMR implementation #502

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Adjust Vite HMR implementation #502

wants to merge 1 commit into from

Conversation

jods4
Copy link

@jods4 jods4 commented Sep 6, 2024

server.reloadModule(mod) is documented as the way to push HMR here: https://vitejs.dev/guide/api-javascript.html#vitedevserver
I've used it in beforeWriteFiles and it worked for me.

I made updateRoutes non-async because:

  • You could await reloadModule but I don't think you should, and you didn't await the websocket in previous code either
  • Everywhere you call updateRoutes, you don't await it.
  • Interface ServerContext says it returns void not Promise.

@posva
Copy link
Owner

posva commented Sep 7, 2024

Thanks, I will have to give it a try. In the end there were other parts that were crucial during HMR like data loaders. I wish it was easier to write unit tests for HMR, it would allow me to make changes more confidently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖 Ready
Development

Successfully merging this pull request may close these issues.

2 participants