fix(ssr): invalid HTML comment tags (#1260)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"$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.0.3",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"$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.0.3"
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
"$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.0.3?external=preact"
|
||||
"preact-render-to-string": "https://esm.sh/preact-render-to-string@6.1.0?external=preact"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"$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.0.3",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"$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.0.3"
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"lock": false,
|
||||
"tasks": {
|
||||
"start": "deno run -A --watch=static/,routes/ dev.ts"
|
||||
},
|
||||
"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@5.2.4",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
}
|
||||
}
|
||||
Executable
+5
@@ -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");
|
||||
@@ -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/Test.tsx";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/index.tsx": $0,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Test.tsx": $$0,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
};
|
||||
|
||||
export default manifest;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { useEffect } from "preact/hooks";
|
||||
|
||||
export default function Test() {
|
||||
useEffect(() => {
|
||||
document.getElementById("foo")!.textContent = "it works";
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<p id="foo">
|
||||
it doesn't work
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <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 routes from "./fresh.gen.ts";
|
||||
import options from "./options.ts";
|
||||
|
||||
const experimentalDenoServe = Deno.args.includes("--experimental-deno-serve");
|
||||
|
||||
await start(routes, { ...options, experimentalDenoServe });
|
||||
@@ -0,0 +1,16 @@
|
||||
// Simulate Deno Deploy environment
|
||||
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
/// <reference lib="deno.ns" />
|
||||
|
||||
import "./polyfill_deno_deploy.ts";
|
||||
import { start } from "$fresh/server.ts";
|
||||
import routes from "./fresh.gen.ts";
|
||||
import options from "./options.ts";
|
||||
|
||||
const experimentalDenoServe = Deno.args.includes("--experimental-deno-serve");
|
||||
|
||||
await start(routes, { ...options, experimentalDenoServe });
|
||||
@@ -0,0 +1,11 @@
|
||||
import { FreshOptions } from "$fresh/server.ts";
|
||||
|
||||
export default {
|
||||
async render(_ctx, render) {
|
||||
await new Promise<void>((r) => r());
|
||||
const body = render();
|
||||
if (typeof body !== "string") {
|
||||
throw new Error("body is missing");
|
||||
}
|
||||
},
|
||||
} as FreshOptions;
|
||||
@@ -0,0 +1,5 @@
|
||||
// Simulate Deno Deploy environment
|
||||
|
||||
//@ts-ignore: Remove Deno.run for simulating deno deploy env
|
||||
// deno-lint-ignore no-deprecated-deno-api
|
||||
delete Deno.run;
|
||||
@@ -0,0 +1,9 @@
|
||||
import Test from "../islands/Test.tsx";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<Test />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
"$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.0.3"
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"$fresh/": "../../",
|
||||
"preact": "https://esm.sh/preact@10.11.0",
|
||||
"preact/": "https://esm.sh/preact@10.11.0/",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.4",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
|
||||
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
assertStringIncludes,
|
||||
delay,
|
||||
Page,
|
||||
@@ -245,3 +246,26 @@ Deno.test({
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "works with older preact-render-to-string v5",
|
||||
|
||||
async fn(_t) {
|
||||
await withPageName(
|
||||
"./tests/fixture_preact_rts_v5/main.ts",
|
||||
async (page) => {
|
||||
await page.goto("http://localhost:8000/", {
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
await page.waitForSelector("#foo");
|
||||
|
||||
await delay(100);
|
||||
const text = await page.$eval("#foo", (el) => el.textContent);
|
||||
assertEquals(text, "it works");
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user