Hi! Currently, tsc, swc, babel, flow ... transpile JSX into new factory function imported from {library}/jsx-runtime with the specific configuration.
For example in tsc, with { "jsx": "react-jsx", "jsxImportSource": "nano-jsx" } will insert import declaration import { jsx } from "nano-jsx/jsx-runtime" and transpile JSX into jsx function call.
I made a support for this.
What I did
I implemented createNode function in ./lib/jsx-runtime. This will simply pass args into h function(because nanojsx has no vdom, so createNode function acts as a simple mediator for h function), and export createNode as jsx, jsxs, jsxDev.
export Fragment also from ./lib/jsx-runtime
I make subpath alias for nano-jsx/jsx-runtime for nano-jsx/lib/jsx-runtime/index.js with exports field in package.json
If you have something unclear or wrong, feel free to point out it.
Motivation
Fix: #21
Hi! Currently, tsc, swc, babel, flow ... transpile JSX into new factory function imported from
{library}/jsx-runtime
with the specific configuration.For example in tsc, with
{ "jsx": "react-jsx", "jsxImportSource": "nano-jsx" }
will insert import declarationimport { jsx } from "nano-jsx/jsx-runtime"
and transpile JSX into jsx function call.I made a support for this.
What I did
I implemented
createNode
function in./lib/jsx-runtime
. This will simply pass args into h function(because nanojsx has no vdom, socreateNode
function acts as a simple mediator forh
function), and exportcreateNode
as jsx, jsxs, jsxDev.export
Fragment
also from./lib/jsx-runtime
I make subpath alias for
nano-jsx/jsx-runtime
fornano-jsx/lib/jsx-runtime/index.js
withexports
field in package.jsonIf you have something unclear or wrong, feel free to point out it.