From c92407ab4700064cdb764ffe96037ece43111973 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Sat, 1 Apr 2023 15:34:50 -0400 Subject: [PATCH] add @eno/app mapping --- deno.json | 4 +++- dummy-app.tsx | 3 +++ server.tsx | 21 ++++++++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 dummy-app.tsx diff --git a/deno.json b/deno.json index 2e7b733..43e76fc 100644 --- a/deno.json +++ b/deno.json @@ -3,7 +3,9 @@ "deno.window", "DOM" ]}, "imports": { - "react-original": "https://esm.sh/react@18.2.0" + "react-original": "https://esm.sh/react@18.2.0", + "react": "https://esm.sh/react@18.2.0", + "@eno/app": "./dummy-app.tsx" }, "tasks": { diff --git a/dummy-app.tsx b/dummy-app.tsx new file mode 100644 index 0000000..70c39dc --- /dev/null +++ b/dummy-app.tsx @@ -0,0 +1,3 @@ +import React from "react"; + +export default ()=>
dummy app
\ No newline at end of file diff --git a/server.tsx b/server.tsx index e4444d5..b59bafa 100644 --- a/server.tsx +++ b/server.tsx @@ -61,7 +61,6 @@ const TranspileURL:Transpiler =async(inPath, inKey, inCheck)=> const LibPath = "lib"; type ImportMap = {imports?:Record, importMap?:string}; -let ImportString = ``; let ImportObject:ImportMap = {}; try { @@ -75,7 +74,6 @@ try try { ImportObject = JSON.parse(confImports); - ImportString = confImports; } catch(e) { @@ -90,22 +88,31 @@ try else if(confDenoParsed.imports) { ImportObject = {imports:confDenoParsed.imports}; - ImportString = JSON.stringify(ImportObject); } if(ImportObject.imports) { - const importReact = ImportObject.imports?.["react"]; + const importReact = ImportObject.imports["react"]; if(importReact) { ImportObject.imports["react-original"] = importReact; ImportObject.imports["react"] = `./${LibPath}/react.tsx`; - ImportString = JSON.stringify(ImportObject); } else { console.log(`"imports" configuration does not alias "react"`); } + + const importApp = ImportObject.imports["@eno/app"]; + if(importApp) + { + + } + else + { + console.log(`"imports" configuration does not alias an entry-point component with "@eno/app"`); + } + } else { @@ -122,7 +129,7 @@ const Index = ` - + @@ -141,7 +148,7 @@ const Index = ` TW.observe(TW.twind(Configure, TW.cssom(ShadowCSS)), ShadowDiv); - import App from "./app.tsx"; + import App from "@eno/app"; import {render, createElement as H} from "react"; render(H(()=>H(App)), ShadowDiv);