I was curious to see how the latest version of Rescript works with the new React compiler, so I’ve managed to setup a minimal project with Next (raw js, typescript added some build complexities). So far it seems that compiled rescript components won’t be memo’d by the new compiler, unfortunately. I assume it happens due to them being compiled to jsx-runtime, which React can’t apply performance updates to. Maybe if we could preserve JSX output from Rescript it might’ve worked.
Here’s the link to the project: long-sandbox-link. Running steps:
-
npm install --forcebecause Rescript dependencies point to React 18. -
npx rescript buildto generate .jsx component -
npm run devto start the next project. - if you are forking the sandbox - open the page in the new window, otherwise CodeSandbox won’t show new compiler messages. If you are running it locally - just open the project url.
Using react component tab in chrome you can see that all components except Rescript were successfully memo’d by the compiler.
