fix: browser not reloaded when no island present (#1956)

This commit is contained in:
Marvin Hagemeister
2023-10-18 11:16:51 +02:00
committed by GitHub
parent 3ad39dbf40
commit b984da9113
15 changed files with 239 additions and 19 deletions
+15
View File
@@ -0,0 +1,15 @@
{
"lock": false,
"imports": {
"$fresh/": "../../",
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.1",
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.5",
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.3.1"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");
+22
View File
@@ -0,0 +1,22 @@
// DO NOT EDIT. This file is generated by Fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/index.tsx";
import * as $1 from "./routes/island.tsx";
import * as $2 from "./routes/no_island.tsx";
import * as $$0 from "./islands/Counter.tsx";
const manifest = {
routes: {
"./routes/index.tsx": $0,
"./routes/island.tsx": $1,
"./routes/no_island.tsx": $2,
},
islands: {
"./islands/Counter.tsx": $$0,
},
baseUrl: import.meta.url,
};
export default manifest;
+12
View File
@@ -0,0 +1,12 @@
import { useSignal } from "@preact/signals";
export default function Counter() {
const sig = useSignal(0);
return (
<div class="counter">
<p>{sig}</p>
<button onClick={() => sig.value++}>update</button>
</div>
);
}
+10
View File
@@ -0,0 +1,10 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
+27
View File
@@ -0,0 +1,27 @@
import * as path from "https://deno.land/std@0.192.0/path/mod.ts";
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
const links: string[] = [];
for (const file of Deno.readDirSync(__dirname)) {
if (file.name.startsWith("index")) continue;
const name = path.basename(file.name, path.extname(file.name));
links.push(name);
}
export default function Home() {
return (
<div>
<h1>Tests</h1>
<ul>
{links.sort().map((link) => {
return (
<li key={link}>
<a href={`/${link}`}>{link}</a>
</li>
);
})}
</ul>
</div>
);
}
+10
View File
@@ -0,0 +1,10 @@
import Counter from "../islands/Counter.tsx";
export default function Home() {
return (
<div class="foo">
<h1>foo</h1>
<Counter />
</div>
);
}
+3
View File
@@ -0,0 +1,3 @@
export default function Home() {
return <h1 class="foo">foo</h1>;
}