Skip to content

Commit

Permalink
fix(dev-server): enable HMR for client-side (#233)
Browse files Browse the repository at this point in the history
* fix(dev-server): enable HMR for client-side

* changeset
  • Loading branch information
yusukebe authored Feb 28, 2025
1 parent ad5a6e8 commit 1dbcbb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-books-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/vite-dev-server': patch
---

fix: enable HMR for client-side
11 changes: 8 additions & 3 deletions packages/dev-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,14 @@ export function devServer(options?: DevServerOptions): VitePlugin {
}
})
},
handleHotUpdate({ server }) {
server.ws.send({ type: 'full-reload' })
return []
handleHotUpdate({ server, modules }) {
// Force reload the page if any of the modules is SSR
const isSSR = modules.some((mod) => mod._ssrModule)
if (isSSR) {
server.hot.send({ type: 'full-reload' })
return []
}
// Apply HMR for the client-side modules
},
config: () => {
return {
Expand Down

0 comments on commit 1dbcbb8

Please sign in to comment.