fix: inject client entry on islands-free pages for HMR (#3810)
Fixes denoland/fresh#3806 --------- Co-authored-by: fibibot <fibibot@users.noreply.github.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
co-authored by
fibibot
Bartek Iwańczuk
parent
1fcf2d9ad5
commit
072d09297e
@@ -165,10 +165,19 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
|
||||
const staticFiles: PendingStaticFile[] = [];
|
||||
let islandMods: IslandModChunk[] = [];
|
||||
let clientEntry = "/@id/fresh:client-entry";
|
||||
let hmrClientEntry: string | undefined;
|
||||
let buildId = "";
|
||||
const entryAssets: string[] = [];
|
||||
|
||||
if (isDev && server !== undefined) {
|
||||
// Set hmrClientEntry so the SSR runtime always emits a boot script
|
||||
// in dev, even when a page has zero islands. Without this, edits
|
||||
// to island-free routes never trigger a browser reload because the
|
||||
// `fresh:reload` WebSocket listener is never attached. The value
|
||||
// is used as a marker only — its presence is what matters, not
|
||||
// what it points to.
|
||||
hmrClientEntry = clientEntry;
|
||||
|
||||
for (const id of islands.keys()) {
|
||||
const mod = server.environments.client.moduleGraph.getModuleById(
|
||||
id,
|
||||
@@ -380,6 +389,7 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
|
||||
staticFiles,
|
||||
buildId,
|
||||
clientEntry,
|
||||
hmrClientEntry,
|
||||
entryAssets,
|
||||
fsRoutesFiles: result.routes,
|
||||
islands: islandMods,
|
||||
|
||||
Reference in New Issue
Block a user