Right now when I use deno run -Ar jsr:@fresh/init to generate a new Fresh site/app and remove all of the code generated (the Counter island, etc.) and just have a routes/index.tsx with some basic HTML, hot module reloading (HMR) breaks. The page does not auto-refresh when I make changes in my editor.
I see in the Fresh source that this is a TODO:
|
// TODO: Implement proper ssr hmr |
|
options.server.hot.send("fresh:reload"); |
Temporary Fix
I found a workaround that does get it working:
diff --git a/routes/_app.tsx b/routes/_app.tsx
index 0225605..f00f73b 100644
--- a/routes/_app.tsx
+++ b/routes/_app.tsx
@@ -7,6 +7,9 @@ export default define.page(function App({ Component }) {
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Fresh Site</title>
+ {import.meta.env.DEV && (
+ <script type="module" src="/@id/fresh:client-entry"></script>
+ )}
</head>
<body>
<Component />
I'm not sure if that's appropriate as a long-term fix though. So I thought I'd open up this GitHub Issue.
It would be great if this just worked out of the box. Especially for server-side rendered apps that don't have any client-side code.
Right now when I use
deno run -Ar jsr:@fresh/initto generate a new Fresh site/app and remove all of the code generated (the Counter island, etc.) and just have aroutes/index.tsxwith some basic HTML, hot module reloading (HMR) breaks. The page does not auto-refresh when I make changes in my editor.I see in the Fresh source that this is a TODO:
fresh/packages/plugin-vite/src/plugins/dev_server.ts
Lines 189 to 190 in 39b5f06
Temporary Fix
I found a workaround that does get it working:
I'm not sure if that's appropriate as a long-term fix though. So I thought I'd open up this GitHub Issue.
It would be great if this just worked out of the box. Especially for server-side rendered apps that don't have any client-side code.