From 65d6d827e36141a096dbb38fdd76fdb08399de48 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Mon, 17 Jul 2023 22:41:22 -0400 Subject: [PATCH] misc cleanup --- hmr-static.tsx | 1 - boot.tsx => run-browser.tsx | 0 run-local.tsx | 1 - run-serve.tsx | 35 +++++++++++++++-------------------- 4 files changed, 15 insertions(+), 22 deletions(-) rename boot.tsx => run-browser.tsx (100%) diff --git a/hmr-static.tsx b/hmr-static.tsx index 9761ab4..7c6dcef 100644 --- a/hmr-static.tsx +++ b/hmr-static.tsx @@ -117,7 +117,6 @@ export const Exports =(inFile:string)=> export const FileExports =async(inURL:string|URL)=> { - console.log("scanning", inURL, "for exports") const resp = await fetch(inURL); const text = await resp.text(); return Exports(text); diff --git a/boot.tsx b/run-browser.tsx similarity index 100% rename from boot.tsx rename to run-browser.tsx diff --git a/run-local.tsx b/run-local.tsx index 43e3d13..b1b1943 100644 --- a/run-local.tsx +++ b/run-local.tsx @@ -45,7 +45,6 @@ Configure({ // we dont need to add ?reload= because this fetch is by way the file system not the hosted url const [local, foreign] = await Collect.FileExports(inConfig.Proxy+inURL.pathname); - console.log(local, foreign); const code =` import {FileListen} from "${import.meta.resolve(`./hmr-listen.tsx`)}"; import * as Import from "${inURL.pathname}?reload=0"; diff --git a/run-serve.tsx b/run-serve.tsx index bb3ebcb..55ff51f 100644 --- a/run-serve.tsx +++ b/run-serve.tsx @@ -11,15 +11,6 @@ Deno.args.forEach(arg=> } }); -const urls = { - Cwd: new URL(`file://${Deno.cwd().replaceAll("\\", "/")}`).toString(), - App: Deno.mainModule, - Mod: import.meta.url, - Look: import.meta.resolve("./boot.tsx") -}; - -console.log(JSON.stringify(urls, null, " ")); - type DenoConfig = {imports:Record}; const ImportMap:DenoConfig = {imports:{}}; let ImportMapOriginal = {}; @@ -41,14 +32,6 @@ const ImportMapReload =async()=> return; } - Object.entries(json.imports).forEach(([key, value])=> - { - if(value.startsWith("./")) - { - json.imports[key] = value.substring(1); - } - }); - if(!json.imports["react"]) { console.log(`"react" specifier not defined in import map`); @@ -58,8 +41,20 @@ const ImportMapReload =async()=> json.imports["react/"] = json.imports["react"]+"/"; } + if(!json.imports["entry"]) + { + console.log(`"entry" specifier not defined in import map.`); + } + + Object.entries(json.imports).forEach(([key, value])=> + { + if(value.startsWith("./")) + { + json.imports[key] = value.substring(1); + } + }); + ImportMap.imports = Configuration.Remap(json.imports, Configuration); - console.log(ImportMap.imports); }; type CustomHTTPHandler = (inReq:Request, inURL:URL, inExt:string|false, inMap:{imports:Record}, inConfig:Configuration)=>void|false|Response|Promise; @@ -91,7 +86,7 @@ let Configuration:Configuration =
@@ -307,7 +302,7 @@ const server = Deno.serve({port:parseInt(Deno.env.get("port")||"8000")}, async(r } else { - throw new Error("404") + throw new Error("404"); } } catch(e)