crank
crank copied to clipboard
jsx-runtime missing
It would be really great if Crank had a jsx-runtime
.
As hint, please find the Preact counterpart here.
Would allow the following tsconfig.json
entries:
"jsx": "react-jsx",
"jsxImportSource": "@b9g/crank"
Hi,
I may be off-track here but the similarities strike me. Note that I'm not using Typescript nor is Babel part of my environment.
I'm using Vite and to build jsx with Crank my vite config esbuild setting contains the following:
export default defineConfig({
esbuild: {
jsxFactory: 'createElement',
jsxFragment: 'Fragment'
}
})
This may be completely unhelpful. My apologies in advance.
Sincerely, Darryl Cousins
@darrylcousins But you still have to import createElement
(and Fragment
if needed) explicitly in each of your component files, don't you? This should not be necessary any longer if you use "jsxImportSource" with a jsx-runtime
.
Hi,
The example offered for esbuild config options is:
export default defineConfig({
esbuild: {
jsxInject: `import React from 'react'`
}
})
I've tested the following and it works. Of course it complains that Identifier 'createElement' has already been declared
if I do explicitly define the import in any jsx file:
export default defineConfig({
esbuild: {
jsxFactory: 'createElement',
jsxFragment: 'Fragment'
jsxInject: `import {createElement, Fragment} from '@b9g/crank'`
}
})
Hope that helps.
Sincere regards, Darryl Cousins
@darrylcousins Thank you very much, Darryl, for all that info about how JSX can be configured with Vite
. This was indeed very informative and helpful.
I've not used Vite
yet, but after your posts above, I'll give it a try ... actually really very nice ...
Nevertheless, as not everybody uses Vite
and jsx-runtime
s are some kind of standard now, it would still be great if Crank
had a jsx-runtime
, I guess :wink:
Hi @xdev1,
Hey, no problem at all. I'm relatively new to nodejs development (python background). I went (sort of) webpack -> brunch -> vite. Most happy with vite. I pass this on to Brian for addressing jsx-runtime
.
Go well, happy coding, Darryl Cousins
Added in 0.5
. Sorry for delay!