From d31dc77412581fa6513083f9470a25f0166b9c9a Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Sun, 6 Nov 2022 13:24:50 +0900 Subject: [PATCH 1/3] fix v4 spec about configuration --- cli/JSXV4.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cli/JSXV4.md b/cli/JSXV4.md index b8f6b0ef..94e31210 100644 --- a/cli/JSXV4.md +++ b/cli/JSXV4.md @@ -22,9 +22,10 @@ To build certain dependencies in V3 compatibility mode, whatever the version use ```json "jsx": { - "version": 4, - "v3-dependencies": ["rescript-react-native", "rescript-react-navigation"] -} + "version": 3, + "v3-dependencies": ["rescript-react-native", "rescript-react-navigation"] +}, +"bsc-flags": ["-open ReactV3"] ``` In V3 compatibility mode, the listed dependencies are built in V3 mode, and in addition `-open ReatcV3` is added to the compiler options, so that the `ReactV3` compatibility module in rescript-react is used. @@ -378,7 +379,6 @@ let p: A.props<_> = {x: "x", y: "y"} V4 introduces support to control the definition of the `props` type by passing as argument to `@react.component` the body of the type definition of `props`. The main application is sharing a single type definition across several components. Here are a few examples: - ```rescript type sharedprops<'x, 'y> = {x: 'x, y: 'y, z:string} @@ -400,6 +400,7 @@ module C3 = { ``` The generated code (some details removed) looks like this: + ```rescript @@jsxConfig({version: 4, mode: "classic"}) From 4c9c40540b9ac0ed9270e75624ef74425b286228 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 6 Nov 2022 14:43:23 +0100 Subject: [PATCH 2/3] Update JSXV4.md --- cli/JSXV4.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cli/JSXV4.md b/cli/JSXV4.md index 94e31210..9d93486a 100644 --- a/cli/JSXV4.md +++ b/cli/JSXV4.md @@ -18,7 +18,9 @@ To build an entire project in V4 mode, including all its dependencies, use the n ### Dependency-level config Dependencies inherit the `jsx` configuration of the root project. So if the root project uses V4 then the dependencies are built using V4, and the same for V3. -To build certain dependencies in V3 compatibility mode, whatever the version used in the root project, use `"v3-dependencies"` as in the example: +To build certain dependencies in V3 compatibility mode, whatever the version used in the root project, use `"v3-dependencies"`: the listed dependencies will be built in V3 mode, and in addition `-open ReatcV3` is added to the compiler options. + +For example, suppose a V3 project uses rescript-react 0.11, which requires compatibility mode if compiled with V3, and that 2 dependencies `"rescript-react-native", "rescript-react-navigation"` only build with compatibility more. Then the setting will be: ```json "jsx": { @@ -28,7 +30,14 @@ To build certain dependencies in V3 compatibility mode, whatever the version use "bsc-flags": ["-open ReactV3"] ``` -In V3 compatibility mode, the listed dependencies are built in V3 mode, and in addition `-open ReatcV3` is added to the compiler options, so that the `ReactV3` compatibility module in rescript-react is used. +Another example is a V4 project that also uses `"rescript-react-native", "rescript-react-navigation"`. Then the setting will be: + +```json +"jsx": { + "version": 4, + "v3-dependencies": ["rescript-react-native", "rescript-react-navigation"] +} +``` > Note: do not add @rescript/react to the v3-dependencies, or it will cause a cyclic dependencies error. From 021acb87e2a3356c4669cfa8b0f57f2c5b0de54e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 6 Nov 2022 14:51:15 +0100 Subject: [PATCH 3/3] Update cli/JSXV4.md Co-authored-by: woonki --- cli/JSXV4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/JSXV4.md b/cli/JSXV4.md index 9d93486a..91280d3c 100644 --- a/cli/JSXV4.md +++ b/cli/JSXV4.md @@ -20,7 +20,7 @@ To build an entire project in V4 mode, including all its dependencies, use the n Dependencies inherit the `jsx` configuration of the root project. So if the root project uses V4 then the dependencies are built using V4, and the same for V3. To build certain dependencies in V3 compatibility mode, whatever the version used in the root project, use `"v3-dependencies"`: the listed dependencies will be built in V3 mode, and in addition `-open ReatcV3` is added to the compiler options. -For example, suppose a V3 project uses rescript-react 0.11, which requires compatibility mode if compiled with V3, and that 2 dependencies `"rescript-react-native", "rescript-react-navigation"` only build with compatibility more. Then the setting will be: +For example, suppose a V3 project uses rescript-react 0.11, which requires compatibility mode if compiled with V3, and that 2 dependencies `"rescript-react-native", "rescript-react-navigation"` only build with compatibility mode. Then the setting will be: ```json "jsx": {