-
Notifications
You must be signed in to change notification settings - Fork 139
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
Option to just compile JSX to object literal #818
Comments
As an example, given: const comp = <>
<div>
<Foo bar={qux}/>
</div>
</>; it would become: const comp = {
_isJsx: true,
tag: '',
attrs: null,
children: [
{
_isJsx: true,
tag: 'div',
attrs: null,
children: [
{
_isJsx: true,
tag: Foo,
attrs: { qux },
children: []
}
]
}
]
} |
Hey @sdegutis , sorry for the delay. Unfortunately I think I'll need to call this request out of scope for Sucrase, at least for now. The goal of Sucrase is to take the most common and well-established transforms and re-implement them in a way that's lighter-weight and more specialized. Part of what makes that reasonable to maintain is to focus on a small number of options rather than allowing lots of configuration in how the transform behaves. I personally would really love it if the community standardized on a new JSX strategy that simply converted it to an object literal, but the current auto-imported function call is what we have today, and it's not the place of the Sucrase project to define a new standard. Of course, if other transpilers started implementing a transform like this, then Sucrase would as well. I realize I'm responding a bit late, but I read about your specific issues and a few thoughts that came to mind that might be helpful:
Hope that's useful. I'll close this issue for now since I think the main request is out of scope for Sucrase. |
Hey everyone, great project. It's part of the basis of my custom runtime for my ssg.
One issue I have right now is that I can't use
jsxRuntime: "automatic"
and control the import it generates. Because my runtime is also intended be compatible with how JS modules work in the browser, I have to manually replace .jsx with .js in the code you generate. Obviously not ideal.Technically I could just request an option to customize what the auto-import path is. But that's still not ideal, because all I'm doing with the JSX you output is just creating object literals at runtime anyway,
Ideally I'd prefer to have an option where JSX is transformed into:
Can we please have this as an option so I don't have to do weird buildtime/runtime hacks to essentially get this behavior anyway?
The text was updated successfully, but these errors were encountered: