diff --git a/deno.json b/deno.json index 8350e18..b3f0c20 100644 --- a/deno.json +++ b/deno.json @@ -7,7 +7,7 @@ { "react":"https://esm.sh/preact@10.15.1/compat", "react-original":"https://esm.sh/preact@10.15.1/compat", - "@app": "./app.tsx" + "@able/": "./_lib_/" }, "tasks": { diff --git a/example/app.tsx b/example/app.tsx index eeeac98..40e1139 100644 --- a/example/app.tsx +++ b/example/app.tsx @@ -1,4 +1,4 @@ -import "../_lib_/boot.tsx"; +import "@able/boot.tsx"; import React from "react"; const CTXString = React.createContext("lol"); @@ -37,7 +37,7 @@ export default ()=> const [Store, Dispatch] = React.useReducer(reducer, {name:"seth", age:24} as Store, builder) return
-

Title?

+

Title????

subtitle!

diff --git a/example/deno.json b/example/deno.json index e10cb86..9ef9dc0 100644 --- a/example/deno.json +++ b/example/deno.json @@ -2,11 +2,12 @@ "compilerOptions": { "lib": ["deno.window", "dom"] }, "imports": { - "react":"https://esm.sh/preact@10.15.1/compat" + "react":"https://esm.sh/preact@10.15.1/compat", + "@able/":"http://localhost:4507/_lib_/" }, "tasks": { - "local": "deno run -A --no-lock app.tsx --dev", - "serve": "deno run -A --no-lock app.tsx" + "local": "deno run -A --no-lock --reload=http://localhost:4507 app.tsx --dev", + "serve": "deno run -A --no-lock --reload=http://localhost:4507 app.tsx" } } \ No newline at end of file diff --git a/local.tsx b/local.tsx index 055c59b..60d17d2 100644 --- a/local.tsx +++ b/local.tsx @@ -20,18 +20,8 @@ Configure({ }, Remap: (inImports)=> { - console.log("running remapper"); - Object.entries(inImports).forEach(([key, value])=> - { - if(value.startsWith("./")) - { - inImports[key] = value.substring(1); - } - }); - inImports["react-original"] = inImports["react"]; inImports["react"] = "/_lib_/react.tsx"; - console.log(inImports); return inImports; }, async Serve(inReq, inURL, inExt, inMap, inProxy) diff --git a/serve.tsx b/serve.tsx index c3f06a0..821c281 100644 --- a/serve.tsx +++ b/serve.tsx @@ -20,7 +20,27 @@ const ImportMapReload =async()=> console.log(`error reading deno config "${path}" message:"${e}"`); return; } + + Object.entries(json.imports).forEach(([key, value])=> + { + if(value.startsWith("./")) + { + json.imports[key] = value.substring(1); + } + }); + if(!json.imports["@able/"]) + { + console.log(`"@able/" specifier not defined in import map`); + } + json.imports["@able/"] = "/_lib_/"; + + if(!json.imports["react"]) + { + console.log(`"react" specifier not defined in import map`); + } + ImportMap.imports = Configuration.Remap(json.imports); + console.log(ImportMap.imports); }; type CustomHTTPHandler = (inReq:Request, inURL:URL, inExt:string|false, inMap:{imports:Record}, inProxy:string)=>void|false|Response|Promise; @@ -35,20 +55,12 @@ let Configuration:Configuration = Serve(inReq, inURL, inExt, inMap, inProxy){}, Remap: (inImports)=> { - Object.entries(inImports).forEach(([key, value])=> - { - if(value.startsWith("./")) - { - inImports[key] = value.substring(1); - } - }); - const reactURL = inImports["react"] ?? console.log("React is not defined in imports"); + const reactURL = inImports["react"]; const setting = Configuration.SWCOp?.jsc?.transform?.react; - if(setting) + if(setting && reactURL) { setting.importSource = reactURL; } - console.log(inImports); return inImports; }, Shell(inReq, inURL, inExt, inMap, inProxy)