add example, fix preact ssr version issue
This commit is contained in:
parent
9b6b7cd8c8
commit
4ff0da09a3
@ -3,14 +3,15 @@
|
|||||||
"deno.window", "DOM"
|
"deno.window", "DOM"
|
||||||
]},
|
]},
|
||||||
"imports": {
|
"imports": {
|
||||||
"react-original": "https://esm.sh/preact@10.11.3/compat",
|
"react-original": "https://esm.sh/preact@10.13.2/compat",
|
||||||
"react": "https://esm.sh/preact@10.11.3/compat",
|
"react": "https://esm.sh/preact@10.13.2/compat",
|
||||||
"@eno/app": "./dummy-app.tsx"
|
"@eno/app": "./dummy-app.tsx"
|
||||||
},
|
},
|
||||||
"tasks":
|
"tasks":
|
||||||
{
|
{
|
||||||
"install": "deno install -f -A --unstable --no-lock -n eno server.tsx",
|
"install": "deno install -f -A --unstable --no-lock -n eno server.tsx",
|
||||||
"run": "deno run -A --unstable --no-lock server.tsx",
|
"run": "deno run -A --unstable --no-lock server.tsx",
|
||||||
|
"complete": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts & cd example && pwd && deno task dev",
|
||||||
"host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts"
|
"host": "deno run -A --unstable https://deno.land/std@0.181.0/http/file_server.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
11
example/app.tsx
Normal file
11
example/app.tsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Component from "./deep/component.tsx";
|
||||||
|
|
||||||
|
export default ()=>{
|
||||||
|
const [countGet, countSet] = React.useState(1);
|
||||||
|
return <div class="p-4 font-sans">
|
||||||
|
<h1 class="my-2 font(bold serif) text(2xl)">Title!!</h1>
|
||||||
|
<h2>subtitle</h2>
|
||||||
|
<Component/>
|
||||||
|
</div>;
|
||||||
|
};
|
9
example/deep/component.tsx
Normal file
9
example/deep/component.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default ()=>
|
||||||
|
{
|
||||||
|
const [countGet, countSet] = React.useState(1);
|
||||||
|
return <div class="p-4 text-red-500">
|
||||||
|
Component!!!
|
||||||
|
</div>;
|
||||||
|
};
|
11
example/deno.json
Normal file
11
example/deno.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"imports":
|
||||||
|
{
|
||||||
|
"react": "https://esm.sh/preact@10.13.2/compat",
|
||||||
|
"@deep/": "./deep/",
|
||||||
|
"@eno/app": "./app.tsx"
|
||||||
|
},
|
||||||
|
"tasks": {
|
||||||
|
"dev": "deno run -A --unstable --reload=http://localhost:4507/ --no-lock --config=deno.json http://localhost:4507/server.tsx"
|
||||||
|
}
|
||||||
|
}
|
@ -73,4 +73,5 @@ const ProxyState =(arg)=>
|
|||||||
|
|
||||||
export * from "react-original";
|
export * from "react-original";
|
||||||
export { ProxyCreate as createElement, ProxyState as useState };
|
export { ProxyCreate as createElement, ProxyState as useState };
|
||||||
export default {...ReactParts.default, createElement:ProxyCreate, useState:ProxyState};
|
export const isProxy = true;
|
||||||
|
export default {...ReactParts.default, createElement:ProxyCreate, useState:ProxyState, isProxy:true};
|
@ -1,8 +1,8 @@
|
|||||||
import * as ESBuild from 'https://deno.land/x/esbuild@v0.14.45/mod.js';
|
import * as ESBuild from 'https://deno.land/x/esbuild@v0.14.45/mod.js';
|
||||||
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts";
|
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts";
|
||||||
import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts";
|
import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts";
|
||||||
import SSR from "https://esm.sh/preact-render-to-string@6.0.2";
|
import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2/deno/preact-render-to-string.mjs";
|
||||||
import React from "react";
|
import React, {createElement as h} from "react";
|
||||||
|
|
||||||
const Transpiled = new Map();
|
const Transpiled = new Map();
|
||||||
const Transpileable =(inFilePath:string):boolean=>
|
const Transpileable =(inFilePath:string):boolean=>
|
||||||
@ -128,8 +128,6 @@ catch(e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const App = await import("@eno/app");
|
const App = await import("@eno/app");
|
||||||
const AppComponent = React.createElement(App.default, null);
|
|
||||||
console.log(`imported app`, App);
|
|
||||||
|
|
||||||
Deno.serve({ port: 3000 }, async(_req:Request) =>
|
Deno.serve({ port: 3000 }, async(_req:Request) =>
|
||||||
{
|
{
|
||||||
@ -231,7 +229,7 @@ FileListen("${url.pathname}", reloadHandler);`;
|
|||||||
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
|
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">${SSR(AppComponent)}</div>
|
<div id="app">${SSR(<App.default/>)}</div>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import * as TW from "https://esm.sh/@twind/core@1.0.1";
|
import * as TW from "https://esm.sh/@twind/core@1.0.1";
|
||||||
import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.0.1";
|
import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.0.1";
|
||||||
|
Loading…
Reference in New Issue
Block a user