Wire to JSX PPX V4 and introduce Jsx* modules#5484
Wire to JSX PPX V4 and introduce Jsx* modules#5484cristianoc merged 11 commits intorescript-lang:masterfrom
Conversation
jscomp/bsb/bsb_config_parse.ml
Outdated
| match flo with | ||
| | "3" -> default := Some Jsx_v3 | ||
| | "4" -> default := Some Jsx_v4 | ||
| | _ -> Bsb_exception.errorf ~loc "Unsupported react-jsx %s" flo) |
There was a problem hiding this comment.
"Unsupported jsx version"
|
Kinda related: is this the time where we could think about moving out of the My ideal world would show something like The original |
It looks good to me. What are the values available for |
|
I’m going to remove the Js.React module which was for the test flight of ppx v4. |
If technically possible, it should be any value. As an example: |
|
Many JS frameworks other than React use JSX today. Preact uses jsx pragma with "h" func: https://preactjs.com/guide/v8/getting-started/#global-pragma Vue also uses "h": https://vuejs.org/guide/extras/render-function.html#JSX Emotion uses "jsx": https://emotion.sh/docs/css-prop#jsx-pragma Theme-UI guides user to customize "jsxImportSource" option: https://theme-ui.com/guides/jsx-pragma/ Btw in case of Emotion/Theme-UI, it allows additional dom props in the file, which is challenging in ReScript I guess |
8c97546 to
dec3057
Compare
81029b3 I've changed the build schema for bsconfig as suggested. "jsx": {
"version": 4,
"module": "react",
"mode": "automatic",
}Actually, |
|
How does one turn on V4? I guess using the new "jsx" config? |
|
Why the name "module". Not a big deal but maybe there's a better name? |
Yes, |
That was from the |
jscomp/bsb/bsb_ninja_rule.ml
Outdated
| (match (has_reason_react_jsx, reason_react_jsx) with | ||
| | false, _ | _, None -> () | ||
| | _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"); | ||
| (match (has_reason_react_jsx, reason_react_jsx, jsx_version) with |
There was a problem hiding this comment.
The first value is never used.
jscomp/frontend/ppx_entry.ml
Outdated
| let ast = | ||
| match !Js_config.jsx_version with | ||
| | 3 -> Reactjs_jsx_ppx_v3.rewrite_signature ast | ||
| | 4 -> Reactjs_jsx_ppx_v4.rewrite_signature !Js_config.jsx_mode ast |
There was a problem hiding this comment.
Style: perhaps use a labeled argument ~jsx_mode here as first argument to Reactjs_jsx_ppx_v4.rewrite_signature.
|
Can you rebase this and point it to the latest syntax PR? |
|
Rebased to master |
|
Looks like it's not pointing to the correct syntax commit. Or some code needs changing. |
|
|
I guess for adding the syntax repo commit here, it's necessary that the syntax PR is done on a branch of the syntax repo, not on a fork. You should be able to do that now. |
Got your invitation, I'll make a branch for V4 in the syntax repo, not from my forked repo, then point to the commit of it. |
I think I've done it. |
|
Done a bit of undocumented black magic to fix CI. Let's see if it works. |
|
OK CI all green now. |
|
Would you merge this on top of master, which already contains the syntax update? |
|
In terms of functionality, can this be merged? |
Yes, I think it is ready to be merged. Let me rebase on top of master. |
|
I've pushed this PR branch to upstream mistakenly, you can ignore or delete it. I was confused where this PR branch belongs to. 😓 I've pushed to my forked repo(origin), and this PR seems updated okay. |
Wire to JSX PPX V4
Companion PR in the syntax repo: rescript-lang/syntax#614
Introduce
Jsx*modulesWIP: AddAddJs.Reactfor the new jsx transform bindingJsxmodule for the primitive types and bindingsJsxDOMwithtype domPropsJsxDOMStyleJsxEvent