From c3e5319d4710a4fb20d9a6c047b6f7604e9f98a3 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Mon, 17 Jul 2023 09:26:41 -0400 Subject: [PATCH] automatically add "react/" --- deno.json | 2 +- example/app.tsx | 30 +++++++++++++++++------------- example/deno.json | 5 +++-- run-serve.tsx | 10 ++++------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/deno.json b/deno.json index c6e7cf7..61c231c 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", - "@able/": "./" + "able/": "http://localhost:1234/" }, "tasks": { diff --git a/example/app.tsx b/example/app.tsx index 35f2003..0f99425 100644 --- a/example/app.tsx +++ b/example/app.tsx @@ -1,3 +1,5 @@ +import { Router, Switch, Case } from "able/iso-elements.tsx"; + import React from "react"; const CTXString = React.createContext("lol"); @@ -35,18 +37,20 @@ export default ()=> { const [Store, Dispatch] = React.useReducer(reducer, {name:"seth", age:24} as Store, builder) return -
-

Title

-

subtitle

-

- -

-
- - - - - - + +
+

Title

+

subtitle

+

+ +

+
+ + + + + + +
; } diff --git a/example/deno.json b/example/deno.json index e55a9d4..a352b2f 100644 --- a/example/deno.json +++ b/example/deno.json @@ -2,8 +2,9 @@ "compilerOptions": { "lib": ["deno.window", "dom"] }, "imports": { - "react":"https://esm.sh/preact@10.15.1/compat", - "entry":"./app.tsx" + "react": "https://esm.sh/preact@10.15.1/compat", + "able/": "http://localhost:1234/", + "entry": "./app.tsx" }, "tasks": { diff --git a/run-serve.tsx b/run-serve.tsx index a2de8f6..bb3ebcb 100644 --- a/run-serve.tsx +++ b/run-serve.tsx @@ -53,6 +53,10 @@ const ImportMapReload =async()=> { console.log(`"react" specifier not defined in import map`); } + else if(!json.imports["react/"]) + { + json.imports["react/"] = json.imports["react"]+"/"; + } ImportMap.imports = Configuration.Remap(json.imports, Configuration); console.log(ImportMap.imports); @@ -70,12 +74,6 @@ let Configuration:Configuration = async Serve(inReq, inURL, inExt, inMap, inConfig){}, Remap: (inImports, inConfig)=> { - const reactURL = inImports["react"]; - const setting = Configuration.SWCOp?.jsc?.transform?.react; - if(setting && reactURL) - { - setting.importSource = reactURL; - } return inImports; }, Shell(inReq, inURL, inExt, inMap, inConfig)