Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit d56c139

Browse files
authored
Fix JSX v4 spec about configuration (#719)
1 parent c4544b4 commit d56c139

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

cli/JSXV4.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,26 @@ To build an entire project in V4 mode, including all its dependencies, use the n
1818
### Dependency-level config
1919

2020
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.
21-
To build certain dependencies in V3 compatibility mode, whatever the version used in the root project, use `"v3-dependencies"` as in the example:
21+
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.
22+
23+
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:
2224

2325
```json
2426
"jsx": {
25-
"version": 4,
26-
"v3-dependencies": ["rescript-react-native", "rescript-react-navigation"]
27-
}
27+
"version": 3,
28+
"v3-dependencies": ["rescript-react-native", "rescript-react-navigation"]
29+
},
30+
"bsc-flags": ["-open ReactV3"]
2831
```
2932

30-
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.
33+
Another example is a V4 project that also uses `"rescript-react-native", "rescript-react-navigation"`. Then the setting will be:
34+
35+
```json
36+
"jsx": {
37+
"version": 4,
38+
"v3-dependencies": ["rescript-react-native", "rescript-react-navigation"]
39+
}
40+
```
3141

3242
> Note: do not add @rescript/react to the v3-dependencies, or it will cause a cyclic dependencies error.
3343
@@ -378,7 +388,6 @@ let p: A.props<_> = {x: "x", y: "y"}
378388

379389
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:
380390

381-
382391
```rescript
383392
type sharedprops<'x, 'y> = {x: 'x, y: 'y, z:string}
384393
@@ -400,6 +409,7 @@ module C3 = {
400409
```
401410

402411
The generated code (some details removed) looks like this:
412+
403413
```rescript
404414
@@jsxConfig({version: 4, mode: "classic"})
405415

0 commit comments

Comments
 (0)