Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update new jsx transform apis, bind to Jsx in compiler, for JSX V4.#49

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
cristianoc merged 37 commits intorescript-lang:masterfrommununki:jsx
Sep 24, 2022

Conversation

@mununki
Copy link
Member

@mununkimununki commentedJun 30, 2022
edited
Loading

This PR introduces the newJsx module in the compiler. This is an initial proposal stage that has objectives and constraints as below.

I don't have a clear picture ofJsx 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.

@@ -0,0 +1,2078 @@
typeelement=React.element
Copy link
Contributor

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-linerinclude M instead.

Copy link
MemberAuthor

@mununkimununkiJul 1, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Your comment reminds me of whatReact andReactDOM stands for, and the same should go forJsx andJsxDOM. I removetype element declaration fromJsxDOM and relocate some to distinguish what they are.
d3eabbee93242b

@cristianoc
Copy link
Contributor

This looks good so far. Let's keep it open until the whole V4 ppx is finalised.

@mununki
Copy link
MemberAuthor

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.

cristianoc reacted with rocket emoji

@mununkimununki mentioned this pull requestJul 1, 2022
13 tasks
@cristianoc
Copy link
Contributor

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?
Did you find some problem, and will document that in a new issue?
Or were no problems found?

@mununki
Copy link
MemberAuthor

mununki commentedJul 1, 2022
edited
Loading

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? Did you find some problem, and will document that in a new issue? Or were no problems found?

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 compilerrescript-lang/rescript#5493

Let me know if anything I can help on that.

cristianoc reacted with thumbs up emoji

@mununki
Copy link
MemberAuthor

mununki commentedJul 2, 2022
edited
Loading

I totally agree on the comment from@ryyppyrescript-lang/rescript#5484 (comment) Here is my thought for the future plan. What do you think?

  1. RemoveJsx from rescript-react.
    If the namespaceJsx is occupied here in rescript-react, there will be a problem(in future graceful migrations) when we addJsx in the compiler.Jsx should be containing the primitive types, functions, modules which are vendors for the 3rd party modules, such as rescript-react, or rescript-solidjs, etc.

  2. Add the new jsx APIs inReact.res andReactDOM.res
    If the upgrade plan is that V4 & the new jsx transform will be shipped with upgrading rescript-react, then we don't need to add a new module here. It is enough to add the new jsx transform React APIs intoReact.res andReactDOM.res Those APIs are just for the React anyway.

  3. AddJsx in the compiler and bind the types to rescript-react
    The initial version ofJsx can be added to the compiler for the experimental feature. Then we can bind the rescript-react toJsx. For example,

// React.restypeelement=Jsx.element// ReactDOM.res@module("react/jsx-runtime")externaljsxKeyed: (string,JsxDOM.domProps,string)=>Jsx.element="jsx"// Jsx in the compiler

Does it make sense to you?

@mununkimununki changed the titleAdd Jsx moduleAdd new jsx transform apis and bind to Jsx in compilerJul 3, 2022
@mununkimununki changed the titleAdd new jsx transform apis and bind to Jsx in compilerUpdate new jsx transform apis, bind to Jsx in compilerJul 3, 2022
@mununki
Copy link
MemberAuthor

The breaking change is introduced by mergingRescriptReact.res intoReact.res.

Side comment: I realized why some of react component binding was not written with@react.component. Simply it is not possible, because the ppx will transform@react.componet usingReact.res itself. 🥲 Therefore, I write the binding without@react.component, but it is compatible with ppx V4.

yarn.lock Outdated
@@ -0,0 +1,3501 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why this file?

Copy link
MemberAuthor

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.

@cristianoc
Copy link
Contributor

How does one test this?
Perhaps one way is to create a separate sample project, which installs the compiler from master, and the rescript-react from this PR, and tests the various things that have changed?

@mununki
Copy link
MemberAuthor

How does one test this? Perhaps one way is to create a separate sample project, which installs the compiler from master, and the rescript-react from this PR, and tests the various things that have changed?

Yes exactly. That is how I develop and test in my local env.

@cristianoc
Copy link
Contributor

cristianoc commentedSep 5, 2022
edited
Loading

How does one test this? Perhaps one way is to create a separate sample project, which installs the compiler from master, and the rescript-react from this PR, and tests the various things that have changed?

Yes exactly. That is how I develop and test in my local env.

Great! Would you create such a project?
That would also be the base example to ask people for feedback.
As it will take a while before both are published in a way that people can try.

@mununki
Copy link
MemberAuthor

How does one test this? Perhaps one way is to create a separate sample project, which installs the compiler from master, and the rescript-react from this PR, and tests the various things that have changed?

Yes exactly. That is how I develop and test in my local env.

Great! Would you create such a project? That would also be the base example to ask people for feedback. As it will take a while before both are published in a way that people can try.

Sure! I'll work on it.

@cristianoc
Copy link
Contributor

Wow! it works! 👍

  • compiler v10.1
  • rescript-react v0.11
  • jsx: {version: 3, v3-dependencies: [rescript-relay]}
  • bs-flags: ["-open ReactV3"]

Still a bit confusing.
It's mainly intended to work when the main project is built with v4.
If the main project is built with v3, it's kind of expected that normal dependencies work out of the box. And they would, if one did not install latest rescript-react.
Thinking...
Perhaps if the main project is build with v3, then there's simply no reason to install latest rescript-react.

@mununki
Copy link
MemberAuthor

mununki commentedSep 21, 2022
edited
Loading

At least we don't need to separate the rescript-react version per compiler and jsx version.

(Before)

  • rescript-react>=0.11.0 for compiler v10.1 + JSX v4
  • rescript-react<0.11.0 for compiler v10.1 + JSX v3

(After)

  • rescript-react>=0.11.0 for compiler v10.1 + JSX v4 or JSX v3

@mununki
Copy link
MemberAuthor

mununki commentedSep 21, 2022
edited
Loading

It's mainly intended to work when the main project is built with v4.

If the main project is with v4, then dependencies are impossible with v3 by all means.

@mununki
Copy link
MemberAuthor

mununki commentedSep 21, 2022
edited
Loading

The option of propagating and v3-dependecies are for the cases, I think
1. dependency is written without@react.component or v3 based. e.g. object props
2. user want to upgrade the compiler v10.1, but have to keep using v3. e.g. async/await
No reason to install the latest rescript-react

@cristianoc
Copy link
Contributor

It's mainly intended to work when the main project is built with v4.

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.
I think there are enough escape hatches to cover corner cases, just in case.
Next up, document the upgrade process better. But to do that it would be nice to have some real upgrade experience, so one can direct the docs to issues that do arise in practice.

Perhaps the way to go is to cover the functionality in the upgrade docs, then do another round of feedback.
Based on responses, one could make updates to the mechanism, or to the docs describing it.

@mununki
Copy link
MemberAuthor

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.

@cristianoc
Copy link
Contributor

Anything to clean up here?
Functionality-wise it seems complete now.

@mununki
Copy link
MemberAuthor

It's like done now.
As I addedbf2f897,legacy directory could be removed once most users are not using v3 anymore.

cristianoc reacted with thumbs up emoji

@cristianoc
Copy link
Contributor

@mattdamon108 any more feedback, anything to change in this PR before merging?
Next up, publish to npm as@rescript/react@next.

@mununki
Copy link
MemberAuthor

@mattdamon108 any more feedback, anything to change in this PR before merging? Next up, publish to npm as@rescript/react@next.

No, it's done.

Copy link
Contributor

@cristianoccristianoc left a 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.

@cristianoc
Copy link
Contributor

@mattdamon108 would you take a look at the checked in.bs.js files? Is everything in them necessary?

mununki reacted with thumbs up emoji

@cristianoccristianoc merged commit86a27d1 intorescript-lang:masterSep 24, 2022
@cristianoccristianoc changed the titleUpdate new jsx transform apis, bind to Jsx in compilerUpdate new jsx transform apis, bind to Jsx in compiler, for JSX V4.Sep 24, 2022
@mununkimununki deleted the jsx branchSeptember 24, 2022 09:23
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cristianoccristianoccristianoc left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@mununki@cristianoc

[8]ページ先頭

©2009-2025 Movatter.jp