Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESBuild options JSXImportSource and JSX #12118

Closed
baltpeter opened this issue Feb 22, 2024 · 2 comments · Fixed by #12119
Closed

Support ESBuild options JSXImportSource and JSX #12118

baltpeter opened this issue Feb 22, 2024 · 2 comments · Fixed by #12119

Comments

@baltpeter
Copy link
Contributor

Hugo already has support for passing the JSXFactory and JSXFragment options to ESBuild:

JSXFactory: opts.JSXFactory,
JSXFragment: opts.JSXFragment,

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:

// @jsxImportSource preact
// @jsxRuntime automatic

If there is interest in supporting those two options, I'm happy to submit a PR. Thanks!

@bep
Copy link
Member

bep commented Feb 22, 2024

I'm happy to submit a PR. Thanks!

Please do.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants