-
Notifications
You must be signed in to change notification settings - Fork 38
Explore JSX preserve mode (i.e. output jsx syntax in the generated code) #539
Comments
I'd like to contribute to this feature. Can you share your initial idea to make this done? IMHO, these should be done for this feature.
|
One thing that came to mind is emitting the js codes separately to JSX would be tricky part. Generally, js expressions are written inside JSX. |
Turning off the jsx ppx entirely doesn't seem feasible for the lower case. For example, the parser will generate the lower case jsx into below.
The type checker would not know what
So that it can be re-transformed to the original JSX by js emitter. |
The compiler is pretty smart in generating code. It's totally possible to have a function that just checks the type without affecting the generated code. |
In my opinion, the way to communicate information to the compiler emitter is by using an attribute. But the JSX PPX removes |
I don't think the mapper visits the same node more than once, so it should be no problem. |
If so, there is no reason to remove |
Oops, I guess the mapper touches more than once, it throws an error.
I think I leave it as they are for V4 task for now, then revisit how it communicates to the compiler emitter later. |
What happens if you turn he check off? Does it generated different code than before? |
After turnning off, it prints as below. I think it is related to the printer. // expected
let make = ({msg}) => ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])
// generated
let make = ({msg}) => <ReactDOMRe.createDOMElementVariadic> </ReactDOMRe.createDOMElementVariadic> |
It seems quite ready to support printing the preserved jsx, I guess. |
Thanks, I guess there's no rush, but it's nice to know that one can preserve that. |
I didn't jump into the preserve jsx feature deeply yet, first thing is first, I still focusing on the JSX PPX V4.
I'll leave the issue about it. 👍 |
@mununki Just registering my interest here 😃 . Would absolutely love this to unlock support for Qwik + Solid (and probably many others) since I love prototyping with Rescript. |
The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions. |
Rough steps
The text was updated successfully, but these errors were encountered: