fix: plugin script error halting JS execution (#1801)

This commit is contained in:
Marvin Hagemeister
2023-09-20 12:28:32 +02:00
committed by GitHub
parent 0c37b5f9b9
commit 3db514f869
8 changed files with 127 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"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.3",
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3",
"@preact/signals-core@1.2.3": "https://esm.sh/@preact/signals-core@1.2.3",
"@preact/signals-core@1.3.0": "https://esm.sh/@preact/signals-core@1.3.0"
},
"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");
+18
View File
@@ -0,0 +1,18 @@
// 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 $$0 from "./islands/Island.tsx";
const manifest = {
routes: {
"./routes/index.tsx": $0,
},
islands: {
"./islands/Island.tsx": $$0,
},
baseUrl: import.meta.url,
};
export default manifest;
@@ -0,0 +1,17 @@
import { useEffect } from "preact/hooks";
import { useSignal } from "@preact/signals";
export default function Island() {
const sig = useSignal(false);
const count = useSignal(0);
useEffect(() => {
sig.value = true;
}, []);
return (
<div id={sig.value ? "ready" : "not-ready"}>
<p>{count}</p>
<button onClick={() => count.value++}>click me</button>
</div>
);
}
+27
View File
@@ -0,0 +1,27 @@
/// <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";
function throwErr() {
throw new Error("Error thrown");
}
await start(manifest, {
plugins: [
{
name: "thrower",
entrypoints: {
main: `data:application/javascript,export default ${throwErr}`,
},
render(ctx) {
ctx.render();
return { scripts: [{ entrypoint: "main", state: {} }] };
},
},
],
});
@@ -0,0 +1,5 @@
import Island from "../islands/Island.tsx";
export default function Home() {
return <Island />;
}