These are unfortunately pretty unergonomic when using Preact. If I use the options "JSXFactory" "h" "JSXFragment" "Fragment", I have to prepend an (otherwise unused) import { h, Fragment } from 'preact'; before every JSX file.
It would probably be possible to work around that using inject, but ESBuild has two newer options that don't require such workarounds anymore, JSXImportSource and JSX: https://esbuild.github.io/api/#jsx-import-source
I would appreciate if it was possible to set these through Hugo. Currently, the only way I've seen to set these would be on a per-file level like this:
Hugo already has support for passing the
JSXFactory
andJSXFragment
options to ESBuild:https://github.com/gohugoio/hugo/blob/16406d9d77cb4861bba9df8ca39e7dadfe41eb45/resources/resource_transformers/js/options.go#L416-L417
These are unfortunately pretty unergonomic when using Preact. If I use the options
"JSXFactory" "h" "JSXFragment" "Fragment"
, I have to prepend an (otherwise unused)import { h, Fragment } from 'preact';
before every JSX file.It would probably be possible to work around that using
inject
, but ESBuild has two newer options that don't require such workarounds anymore,JSXImportSource
andJSX
: https://esbuild.github.io/api/#jsx-import-sourceI would appreciate if it was possible to set these through Hugo. Currently, the only way I've seen to set these would be on a per-file level like this:
If there is interest in supporting those two options, I'm happy to submit a PR. Thanks!