automatically add "react/"

This commit is contained in:
Seth Trowbridge 2023-07-17 09:26:41 -04:00
parent 3fed5dfdba
commit c3e5319d47
4 changed files with 25 additions and 22 deletions

View File

@ -7,7 +7,7 @@
{ {
"react":"https://esm.sh/preact@10.15.1/compat", "react":"https://esm.sh/preact@10.15.1/compat",
"react-original":"https://esm.sh/preact@10.15.1/compat", "react-original":"https://esm.sh/preact@10.15.1/compat",
"@able/": "./" "able/": "http://localhost:1234/"
}, },
"tasks": "tasks":
{ {

View File

@ -1,3 +1,5 @@
import { Router, Switch, Case } from "able/iso-elements.tsx";
import React from "react"; import React from "react";
const CTXString = React.createContext("lol"); const CTXString = React.createContext("lol");
@ -35,18 +37,20 @@ export default ()=>
{ {
const [Store, Dispatch] = React.useReducer(reducer, {name:"seth", age:24} as Store, builder) const [Store, Dispatch] = React.useReducer(reducer, {name:"seth", age:24} as Store, builder)
return <CTXString.Provider value="intradestink"> return <CTXString.Provider value="intradestink">
<div class="my-4 font-sans"> <Router.Provider>
<h1 class="font-black text-xl text-red-500">Title</h1> <div class="my-4 font-sans">
<h2 class="font-black text-blue-500">subtitle</h2> <h1 class="font-black text-xl text-red-500">Title</h1>
<p> <h2 class="font-black text-blue-500 p-4">subtitle</h2>
<button onClick={e=>Dispatch(1)}>{Store.name}|{Store.age}?</button> <p>
</p> <button onClick={e=>Dispatch(1)}>{Store.name}|{Store.age}?</button>
</div> </p>
<Outer> </div>
<Inner/> <Outer>
</Outer> <Inner/>
<Outer> </Outer>
<Inner/> <Outer>
</Outer> <Inner/>
</Outer>
</Router.Provider>
</CTXString.Provider>; </CTXString.Provider>;
} }

View File

@ -2,8 +2,9 @@
"compilerOptions": { "lib": ["deno.window", "dom"] }, "compilerOptions": { "lib": ["deno.window", "dom"] },
"imports": "imports":
{ {
"react":"https://esm.sh/preact@10.15.1/compat", "react": "https://esm.sh/preact@10.15.1/compat",
"entry":"./app.tsx" "able/": "http://localhost:1234/",
"entry": "./app.tsx"
}, },
"tasks": "tasks":
{ {

View File

@ -53,6 +53,10 @@ const ImportMapReload =async()=>
{ {
console.log(`"react" specifier not defined in import map`); 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); ImportMap.imports = Configuration.Remap(json.imports, Configuration);
console.log(ImportMap.imports); console.log(ImportMap.imports);
@ -70,12 +74,6 @@ let Configuration:Configuration =
async Serve(inReq, inURL, inExt, inMap, inConfig){}, async Serve(inReq, inURL, inExt, inMap, inConfig){},
Remap: (inImports, inConfig)=> Remap: (inImports, inConfig)=>
{ {
const reactURL = inImports["react"];
const setting = Configuration.SWCOp?.jsc?.transform?.react;
if(setting && reactURL)
{
setting.importSource = reactURL;
}
return inImports; return inImports;
}, },
Shell(inReq, inURL, inExt, inMap, inConfig) Shell(inReq, inURL, inExt, inMap, inConfig)