I created a test app with npx create-rescript-app, switched to rescript v12 and replaced react with solidjs.
The first impression is very promising. The app compiled without problems and solidjs could handle the generated jsx files well
.
So preserve mode seems to be working with solidjs, which is great!
But sadly, I immediately ran into a problem with reactivity. This is not related to JSX preserve mode, but would still require an additional transformation step to make the code work.
In the example code there is a button component:
let make = props =>
<button
{...
props}
className="bg-blue-600 text-white"
/>
that is compiled to:
function make(props) {
let newrecord = {...props};
return <button {...newrecord} className={"bg-blue-600 text-white"}/>;
}
The line let newrecord = {...props}; breaks reactivity since it basically copies all properties.
The line only appears when additional classes are added to the button component.
This button:
let make = props =>
<button {...props} />
would compile to:
function make(props) {
return <button {...props} />;
}
and works just fine.
I have to do further tests to see if there are any other problems, but still, getting rid of the “js-back-to-jsx” babel-transform, that is currently necessary, is a great step forward.