better jsx mapper, versatile jsx config

This commit is contained in:
Seth Trowbridge 2025-10-10 19:30:04 -04:00
parent bfeb85b674
commit ebcce354d0
2 changed files with 7 additions and 5 deletions

View File

@ -49,7 +49,7 @@ export const HMR =
export type StateType = boolean|number|string|Record<string, string>
export type StateCapture = {state:StateType, set:ReactParts.StateUpdater<StateType>, reload:number};
type FuncArgs = [element:keyof ReactParts.JSX.IntrinsicElements, props:Record<string, string>, children:ReactParts.JSX.Element[]];
type FuncArgs = [element:keyof ReactParts.JSX.IntrinsicElements, props:Record<string, string>, children?:ReactParts.JSX.Element[]];
const H = ReactParts.createElement;
@ -172,6 +172,8 @@ const ProxyReducer =(inReducer:(inState:Storelike, inAction:string)=>Storelike,
};
export * from "react-original";
const Fragment = ReactParts.Fragment;
export {ProxyCreate as createElement, ProxyCreate as jsx, ProxyCreate as jsxs, Fragment, ProxyState as useState, ProxyReducer as useReducer };
export default {...ReactParts, createElement:ProxyCreate, jsx:ProxyCreate, jsxs:ProxyCreate, Fragment, useState:ProxyState, useReducer:ProxyReducer};
const ProxyFragment = ReactParts.Fragment;
const ProxyJSX = (type:keyof ReactParts.JSX.IntrinsicElements, props:object, key:string)=>ProxyCreate(type, {...props, key});
export {ProxyCreate as createElement, ProxyJSX as jsx, ProxyJSX as jsxs, ProxyFragment as Fragment, ProxyState as useState, ProxyReducer as useReducer };
export default {...ReactParts, createElement:ProxyCreate, jsx:ProxyJSX, jsxs:ProxyJSX, Fragment: ProxyFragment, useState:ProxyState, useReducer:ProxyReducer};

View File

@ -90,7 +90,7 @@ for(const key in denoBody.imports)
denoBody.imports[key] = "/>/"+value;
}
}
const react = denoBody.compilerOptions.jsxImportSource;
const react = denoBody.compilerOptions.jsxImportSource || "react";
denoBody.imports["react-original"] = denoBody.imports[react];
denoBody.imports[react] = "/^/hmr/hmr-react.tsx";
denoBody.imports[react+"/jsx-runtime"] = "/^/hmr/hmr-react.tsx";