feat: add support for jsx precompile (#2035)
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
_fresh/
|
_fresh/
|
||||||
tmp/
|
tmp/
|
||||||
|
vendor/
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export const RECOMMENDED_PREACT_VERSION = "10.18.1";
|
export const RECOMMENDED_PREACT_VERSION = "10.19.1";
|
||||||
export const RECOMMENDED_PREACT_SIGNALS_VERSION = "1.2.1";
|
export const RECOMMENDED_PREACT_SIGNALS_VERSION = "1.2.1";
|
||||||
export const RECOMMENDED_PREACT_SIGNALS_CORE_VERSION = "1.5.0";
|
export const RECOMMENDED_PREACT_SIGNALS_CORE_VERSION = "1.5.0";
|
||||||
export const RECOMMENDED_TWIND_VERSION = "0.16.19";
|
export const RECOMMENDED_TWIND_VERSION = "0.16.19";
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ export {
|
|||||||
export { toHashString } from "https://deno.land/std@0.205.0/crypto/to_hash_string.ts";
|
export { toHashString } from "https://deno.land/std@0.205.0/crypto/to_hash_string.ts";
|
||||||
export { escape } from "https://deno.land/std@0.205.0/regexp/escape.ts";
|
export { escape } from "https://deno.land/std@0.205.0/regexp/escape.ts";
|
||||||
export * as JSONC from "https://deno.land/std@0.205.0/jsonc/mod.ts";
|
export * as JSONC from "https://deno.land/std@0.205.0/jsonc/mod.ts";
|
||||||
export { renderToString } from "https://esm.sh/*preact-render-to-string@6.2.2";
|
export { renderToString } from "https://esm.sh/*preact-render-to-string@6.3.0";
|
||||||
export {
|
export {
|
||||||
assertEquals,
|
assertEquals,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"lock": false,
|
||||||
|
"compilerOptions": {
|
||||||
|
"jsx": "precompile",
|
||||||
|
"jsxImportSource": "preact"
|
||||||
|
},
|
||||||
|
"imports": {
|
||||||
|
"$fresh/": "../../",
|
||||||
|
"preact": "https://esm.sh/preact@10.19.1",
|
||||||
|
"preact/": "https://esm.sh/preact@10.19.1/"
|
||||||
|
}
|
||||||
|
}
|
||||||
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,21 @@
|
|||||||
|
// 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 $head from "./routes/head.tsx";
|
||||||
|
import * as $index from "./routes/index.tsx";
|
||||||
|
import * as $$Island from "./islands/Island.tsx";
|
||||||
|
import { Manifest } from "$fresh/server.ts";
|
||||||
|
|
||||||
|
const manifest = {
|
||||||
|
routes: {
|
||||||
|
"./routes/head.tsx": $head,
|
||||||
|
"./routes/index.tsx": $index,
|
||||||
|
},
|
||||||
|
islands: {
|
||||||
|
"./islands/Island.tsx": $$Island,
|
||||||
|
},
|
||||||
|
baseUrl: import.meta.url,
|
||||||
|
} satisfies Manifest;
|
||||||
|
|
||||||
|
export default manifest;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export default function Island() {
|
||||||
|
return (
|
||||||
|
<p class="island">
|
||||||
|
it works
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/// <reference no-default-lib="true" />
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
/// <reference lib="dom.asynciterable" />
|
||||||
|
/// <reference lib="deno.ns" />
|
||||||
|
|
||||||
|
import { start } from "$fresh/server.ts";
|
||||||
|
import manifest from "./fresh.gen.ts";
|
||||||
|
await start(manifest);
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Head } from "$fresh/runtime.ts";
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Head>
|
||||||
|
<title>foo</title>
|
||||||
|
<meta name="foo" content="bar" />
|
||||||
|
</Head>
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import Island from "../islands/Island.tsx";
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
<Island />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -55,3 +55,25 @@ Deno.test("render head text nodes", async () => {
|
|||||||
assertEquals(doc.body.textContent, "hello");
|
assertEquals(doc.body.textContent, "hello");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("support jsx precompile", async () => {
|
||||||
|
await withFakeServe(
|
||||||
|
"./tests/fixture_jsx_precompile/main.ts",
|
||||||
|
async (server) => {
|
||||||
|
const doc = await server.getHtml("/");
|
||||||
|
assertTextMany(doc, "h1", ["Hello World"]);
|
||||||
|
assertTextMany(doc, ".island", ["it works"]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("support <Head /> with jsx precompile", async () => {
|
||||||
|
await withFakeServe(
|
||||||
|
"./tests/fixture_jsx_precompile/main.ts",
|
||||||
|
async (server) => {
|
||||||
|
const doc = await server.getHtml("/head");
|
||||||
|
assertTextMany(doc, "h1", ["Hello World"]);
|
||||||
|
assertTextMany(doc, "head title", ["foo"]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user