-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update new jsx transform apis, bind to Jsx in compiler, for JSX V4. #49
Conversation
src/JsxDOM.res
Outdated
@@ -0,0 +1,2078 @@ | |||
type element = React.element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a verbatim copy of another file in the repo?
That could be a problem when someone wants to edit something.
Better to have only once. And in the copy do a one-liner include M
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good so far. Let's keep it open until the whole V4 ppx is finalised. |
Side comment: I verified that V4 & Jsx don't break my test project having dependencies of V3 modules. So, I tried to run the battle-test of V10 & V4 & Jsx on my company projects. I encountered some errors before verifying that V4 & classic, V4 & Jsx will not break the backward compatibility. I'll leave the issue in the compiler. |
Can you expand a bit on this? |
I ran V10 & V4 & Jsx on my test project which is a small RescriptReact app. It has dependencies of the RescriptReact module I made with V3 bsconfig. I've tested the scenarios (V3, V4 & classic, V4 & Jsx), and they worked fine. But I ran V10 compiler in V3 mode on large applications(company projects), it throws several errors. I guess it is not related to V4 or Jsx. So I left the issue in the compiler rescript-lang/rescript#5493 Let me know if anything I can help on that. |
I totally agree on the comment from @ryyppy rescript-lang/rescript#5484 (comment) Here is my thought for the future plan. What do you think?
// React.res
type element = Jsx.element
// ReactDOM.res
@module("react/jsx-runtime")
external jsxKeyed: (string, JsxDOM.domProps, string) => Jsx.element = "jsx" // Jsx in the compiler Does it make sense to you? |
The breaking change is introduced by merging Side comment: I realized why some of react component binding was not written with |
yarn.lock
Outdated
@@ -0,0 +1,3501 @@ | |||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, my mistake. I'll drop it.
How does one test this? |
Yes exactly. That is how I develop and test in my local env. |
Great! Would you create such a project? |
Sure! I'll work on it. |
Still a bit confusing. |
At least we don't need to separate the rescript-react version per compiler and jsx version. (Before)
(After)
|
If the main project is with v4, then dependencies are impossible with v3 by all means. |
|
Not beautiful, but it's possible to switch to V3 inside a V4 project, and use a V3 dependency. Perhaps the way to go is to cover the functionality in the upgrade docs, then do another round of feedback. |
Not perfect, but the v3 and v4 apps can use the same latest rescript-react with options you've made. I think this backward compatibility of rescript-react would be a benefit for many users. |
Anything to clean up here? |
It's like done now. |
@mattdamon108 any more feedback, anything to change in this PR before merging? |
No, it's done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments.
I think we should check in generated js files.
It's not 100% zero generated code anymore for technical reasons, so whatever this produces should be checked in. So we see if it's all needed.
@mattdamon108 would you take a look at the checked in |
This PR introduces the new
Jsx
module in the compiler. This is an initial proposal stage that has objectives and constraints as below.The newAdded in the compiler Wire to JSX PPX V4 and introduce Jsx* modules rescript#5484domProps
andprops
types which are declared with@optional
attributeThe newAdded in the compiler Wire to JSX PPX V4 and introduce Jsx* modules rescript#5484JsxDOMStyle
moduleI don't have a clear picture of
Jsx
in the future. It could define the primitive types, functions, and modules that are vendors for JSX family, such as React, SolidJs, Remix in future. But I focus to keep the backward compatibility and support for the new jsx mode of React runtime in this stage for now.