[RFC] Exploring Preserve Mode in ReScript: Your Thoughts and Use Cases

I would like to bring your attention to an open GitHub issue discussing the implementation of Preserve Mode in ReScript. For those unfamiliar, Preserve Mode is a feature that maintains the original formatting and structure of JSX expressions in the JavaScript output generated by the ReScript compiler.

This feature could potentially enhance the readability and maintainability of the compiled output containing JSX, making it easier for developers to work with and understand the generated code. Furthermore, Preserve Mode could allow for better compatibility with frameworks like Preact and SolidJS, expanding the reach and applicability of ReScript.


let make = () => {
  let (user, setUser) = React.Uncurried.useState(_ => "mununki")

    <p> {`${user} uses ReScript`->React.string} </p>
    <input value=user onChange={e => setUser(._ => (e->JsxEventC.Form.target)["value"])} />

preserved JSX

function Preserve(props) {
  var match = React.useState(function (param) {
    return "mununki";
  var setUser = match[1];
  var user = match[0];
  return (
      <p> user + " uses ReScript" </p>
        onChange={function (e) {
          setUser(function (param) {
            return e.target.value;

We would love to hear your thoughts on Preserve Mode and how it could be beneficial to the ReScript community. Additionally, if you have any use cases or scenarios where Preserve Mode would be particularly useful, please share them with us.

We’re also interested in understanding which specific frameworks you think could benefit from this feature and how their individual requirements may differ with respect to Preserve Mode. Your feedback will be invaluable in determining whether this feature should be considered for future development and how it can be tailored to suit the needs of various frameworks.

Thank you for your input!


For supporting SolidJS, this and uncurried mode will be required I think.

@Fattafatta made an Issue about some open problems when using Solid with ReScript: Assessment: native solidJS support in rescript · Issue #14 · Fattafatta/rescript-solidjs · GitHub


Thanks, that looks good example of requirements for SolidJS

If it lets SolidJs work, then I’m for it.

1 Like

The ability to use SolidJS with Rescript is what i’m waiting for so badly :sweat_smile:
Please, free me from Typescript :rofl:


This is a good read. There’s several other “issues” wrt the generated code for use with SolidJs. So using SolidJs probably shouldn’t be the sole motivator for a preserve mode.