Hey all,
This post is intended to give recent work more visibility and coordinate efforts for the potential JSX changes and updates on @rescript/react
.
JSX
The compiler introduced a very crucial feature that may help us to drastically reduce the logic of the JSX / @react.component transforms. We are currently in the exploration and planning phase on how the new JSX transform could look like.
The GH issue for the meta discussion can be found here: https://github.com/rescript-lang/syntax/issues/521. We still need to assess all the requirements / wishes the new transform should bring, without introducing any breaking changes. So feel free to join the discussion.
Later on we may want to put the results of our explorations into a proper document (maybe in form of a PR to the syntax repo?) to persist the design intentions.
General goals / constraints for the new JSX design:
- Remove as much magic / use the language as much as possible (makeProps, make may not be needed anymore?) → less magic = less complexity = better tooling support and maintainability
- Make sure JSX v3 code mixes gracefully with JSX v4 code. Existing code should compile as usual, even with different settings enabled
- JSX v4 should ideally work without any additional changes to rescript-react.
First explorations on the new transform can be found in this PR: https://github.com/rescript-lang/syntax/pull/517 (the title may be a little misleading).
In later iterations, we’d like to explore how to make the JSX more flexible for other frameworks, and even consider JSX related settings similar to TS (e.g. emit settings like preserve
). The new React transform and fulfilling fast-refresh requirements will also be part of that.
rescript-react
There were some blockers for rescript-react
until we shipped the new JSX. Now that the JSX plans are re-organized, I think we should move on with new 0.10.x releases, and accept new contributions to e.g. support React 18 features OOTB.
I am not invested in any of the new React@18 functionality myself (I am mostly stuck on v16 rn and Ricky is a little too busy to help out here), so I am happy for any changes from contributors that use React@18 and ReScript that are reliant on the code. (\cc @tom-sherman / whitchapman who recently created PRs on that front). We should also make sure that the React docs on rescript-lang .org are in sync with these changes.
PR by Tom: https://github.com/rescript-lang/rescript-react/pull/35
PR by Whit: https://github.com/rescript-lang/rescript-react/pull/46
^-- not sure what the states are here, so more coordination may be required?
Please use the corresponding issues / PRs for input if applicable.