Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/server-environments-reload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'vite-plugin-solid': patch
---

Send non-client server environments their own full-reload signal during hot
updates. Environment-runner based servers now re-evaluate changed modules
instead of serving stale SSR output, while client HMR remains unaffected.
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,21 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin[] {
} as typeof hot.send;
},

hotUpdate() {
hotUpdate({ modules }) {
// solid-refresh only injects HMR boundaries into client modules, so
// non-client environments have no accept handlers. Without this, Vite
// would see no boundaries and send full-reload messages that race with
// client-side HMR updates.
if (this.environment.name !== 'client') {
// Returning [] also suppresses the signal environment-runner based
// servers (e.g. nitro's dev worker) rely on to re-evaluate modules,
// leaving SSR stale until a manual restart. Send the reload on this
// environment's own channel — for runner-based environments that is
// the runner, for the default ssr environment a no-op, and never the
// browser websocket, so client HMR stays free of full-reload races.
if (modules.length > 0) {
this.environment.hot.send({ type: 'full-reload' });
}
return [];
}
},
Expand Down
Loading