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

Commit d3b5505

Browse files
committed
check each module has one react comp at most
1 parent 8bc3e5d commit d3b5505

13 files changed

+778
-769
lines changed

cli/reactjs_jsx_ppx.ml

Lines changed: 366 additions & 354 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
@@jsxConfig({version: 3})
2-
@obj external makeProps: (~msg: 'msg, ~key: string=?, unit) => {"msg": 'msg} = ""
32

4-
@react.component
5-
let make =
6-
(@warning("-16") ~msg) => {
7-
ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])
3+
module V3 = {
4+
@obj external makeProps: (~msg: 'msg, ~key: string=?, unit) => {"msg": 'msg} = ""
5+
6+
@react.component
7+
let make =
8+
(@warning("-16") ~msg) => {
9+
ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])
10+
}
11+
let make = {
12+
let \"FileLevelConfig$V3" = (\"Props": {"msg": 'msg}) => make(~msg=\"Props"["msg"])
13+
\"FileLevelConfig$V3"
814
}
9-
let make = {
10-
let \"FileLevelConfig" = (\"Props": {"msg": 'msg}) => make(~msg=\"Props"["msg"])
11-
\"FileLevelConfig"
1215
}
1316

1417
@@jsxConfig({version: 4, mode: "classic"})
15-
type props<'msg> = {key?: string, msg: 'msg}
1618

17-
@react.component
18-
let make = ({msg, _}: props<'msg>) => {
19-
ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])
20-
}
21-
let make = {
22-
let \"FileLevelConfig" = (props: props<_>) => make(props)
23-
\"FileLevelConfig"
19+
module V4C = {
20+
type props<'msg> = {key?: string, msg: 'msg}
21+
22+
@react.component
23+
let make = ({msg, _}: props<'msg>) => {
24+
ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])
25+
}
26+
let make = {
27+
let \"FileLevelConfig$V4C" = (props: props<_>) => make(props)
28+
\"FileLevelConfig$V4C"
29+
}
2430
}
2531

2632
@@jsxConfig({version: 4, mode: "automatic"})
27-
type props<'msg> = {key?: string, msg: 'msg}
2833

29-
@react.component
30-
let make = ({msg, _}: props<'msg>) => {
31-
ReactDOM.jsx("div", {children: {msg->React.string}})
32-
}
33-
let make = {
34-
let \"FileLevelConfig" = (props: props<_>) => make(props)
35-
\"FileLevelConfig"
34+
module V4A = {
35+
type props<'msg> = {key?: string, msg: 'msg}
36+
37+
@react.component
38+
let make = ({msg, _}: props<'msg>) => {
39+
ReactDOM.jsx("div", {children: {msg->React.string}})
40+
}
41+
let make = {
42+
let \"FileLevelConfig$V4A" = (props: props<_>) => make(props)
43+
\"FileLevelConfig$V4A"
44+
}
3645
}
Lines changed: 144 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,175 @@
11
@@jsxConfig({version: 3})
22

3-
module FancyInput = {
4-
@obj
5-
external makeProps: (
6-
~className: 'className=?,
7-
~children: 'children,
8-
~key: string=?,
9-
~ref: 'ref=?,
10-
unit,
11-
) => {"className": option<'className>, "children": 'children} = ""
3+
module V3 = {
4+
module FancyInput = {
5+
@obj
6+
external makeProps: (
7+
~className: 'className=?,
8+
~children: 'children,
9+
~key: string=?,
10+
~ref: 'ref=?,
11+
unit,
12+
) => {"className": option<'className>, "children": 'children} = ""
1213

13-
@react.component
14-
let make =
15-
(@warning("-16") ~className=?, @warning("-16") ~children) =>
16-
@warning("-16")
17-
ref =>
18-
ReactDOMRe.createDOMElementVariadic(
19-
"div",
20-
[
21-
ReactDOMRe.createDOMElementVariadic(
22-
"input",
23-
~props=ReactDOMRe.domProps(
24-
~type_="text",
25-
~className?,
26-
~ref=?{Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef)},
27-
(),
14+
@react.component
15+
let make =
16+
(@warning("-16") ~className=?, @warning("-16") ~children) =>
17+
@warning("-16")
18+
ref =>
19+
ReactDOMRe.createDOMElementVariadic(
20+
"div",
21+
[
22+
ReactDOMRe.createDOMElementVariadic(
23+
"input",
24+
~props=ReactDOMRe.domProps(
25+
~type_="text",
26+
~className?,
27+
~ref=?{Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef)},
28+
(),
29+
),
30+
[],
2831
),
29-
[],
30-
),
31-
children,
32-
],
33-
)
34-
let make = React.forwardRef({
35-
let \"ForwardRef$FancyInput" = (
36-
\"Props": {"className": option<'className>, "children": 'children},
37-
ref,
38-
) => make(~children=\"Props"["children"], ~className=?\"Props"["className"], ref)
39-
\"ForwardRef$FancyInput"
40-
})
41-
}
42-
@obj external makeProps: (~key: string=?, unit) => {.} = ""
32+
children,
33+
],
34+
)
35+
let make = React.forwardRef({
36+
let \"ForwardRef$V3$FancyInput" = (
37+
\"Props": {"className": option<'className>, "children": 'children},
38+
ref,
39+
) => make(~children=\"Props"["children"], ~className=?\"Props"["className"], ref)
40+
\"ForwardRef$V3$FancyInput"
41+
})
42+
}
43+
@obj external makeProps: (~key: string=?, unit) => {.} = ""
4344

44-
@react.component
45-
let make = () => {
46-
let input = React.useRef(Js.Nullable.null)
45+
@react.component
46+
let make = () => {
47+
let input = React.useRef(Js.Nullable.null)
4748

48-
ReactDOMRe.createDOMElementVariadic(
49-
"div",
50-
[
51-
React.createElement(
52-
FancyInput.make,
53-
FancyInput.makeProps(~ref=input, ~children={React.string("Click to focus")}, ()),
54-
),
55-
],
56-
)
57-
}
58-
let make = {
59-
let \"ForwardRef" = (\"Props": {.}) => make()
60-
\"ForwardRef"
49+
ReactDOMRe.createDOMElementVariadic(
50+
"div",
51+
[
52+
React.createElement(
53+
FancyInput.make,
54+
FancyInput.makeProps(~ref=input, ~children={React.string("Click to focus")}, ()),
55+
),
56+
],
57+
)
58+
}
59+
let make = {
60+
let \"ForwardRef$V3" = (\"Props": {.}) => make()
61+
\"ForwardRef$V3"
62+
}
6163
}
6264

6365
@@jsxConfig({version: 4, mode: "classic"})
6466

65-
module FancyInput = {
66-
type props<'className, 'children> = {
67-
key?: string,
68-
ref?: ReactDOM.Ref.currentDomRef,
69-
className?: 'className,
70-
children: 'children,
67+
module V4C = {
68+
module FancyInput = {
69+
type props<'className, 'children> = {
70+
key?: string,
71+
ref?: ReactDOM.Ref.currentDomRef,
72+
className?: 'className,
73+
children: 'children,
74+
}
75+
76+
@react.component
77+
let make = ({?className, children, _}: props<'className, 'children>, ref) =>
78+
ReactDOMRe.createDOMElementVariadic(
79+
"div",
80+
[
81+
ReactDOMRe.createDOMElementVariadic(
82+
"input",
83+
~props=ReactDOMRe.domProps(
84+
~type_="text",
85+
~className?,
86+
~ref=?{Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef)},
87+
(),
88+
),
89+
[],
90+
),
91+
children,
92+
],
93+
)
94+
let make = React.forwardRef({
95+
let \"ForwardRef$V4C$FancyInput" = (props: props<_>, ref) => make(props, ref)
96+
\"ForwardRef$V4C$FancyInput"
97+
})
7198
}
99+
type props = {key?: string}
72100

73101
@react.component
74-
let make = ({?className, children, _}: props<'className, 'children>, ref) =>
102+
let make = (_: props) => {
103+
let input = React.useRef(Js.Nullable.null)
104+
75105
ReactDOMRe.createDOMElementVariadic(
76106
"div",
77107
[
78-
ReactDOMRe.createDOMElementVariadic(
79-
"input",
80-
~props=ReactDOMRe.domProps(
81-
~type_="text",
82-
~className?,
83-
~ref=?{Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef)},
84-
(),
85-
),
86-
[],
108+
React.createElement(
109+
FancyInput.make,
110+
{ref: input, children: {React.string("Click to focus")}},
87111
),
88-
children,
89112
],
90113
)
91-
let make = React.forwardRef({
92-
let \"ForwardRef$FancyInput" = (props: props<_>, ref) => make(props, ref)
93-
\"ForwardRef$FancyInput"
94-
})
95-
}
96-
type props = {key?: string}
97-
98-
@react.component
99-
let make = (_: props) => {
100-
let input = React.useRef(Js.Nullable.null)
101-
102-
ReactDOMRe.createDOMElementVariadic(
103-
"div",
104-
[
105-
React.createElement(
106-
FancyInput.make,
107-
{ref: input, children: {React.string("Click to focus")}},
108-
),
109-
],
110-
)
111-
}
112-
let make = {
113-
let \"ForwardRef" = props => make(props)
114-
\"ForwardRef"
114+
}
115+
let make = {
116+
let \"ForwardRef$V4C" = props => make(props)
117+
\"ForwardRef$V4C"
118+
}
115119
}
116120

117121
@@jsxConfig({version: 4, mode: "automatic"})
118122

119-
module FancyInput = {
120-
type props<'className, 'children> = {
121-
key?: string,
122-
ref?: ReactDOM.Ref.currentDomRef,
123-
className?: 'className,
124-
children: 'children,
123+
module V4A = {
124+
module FancyInput = {
125+
type props<'className, 'children> = {
126+
key?: string,
127+
ref?: ReactDOM.Ref.currentDomRef,
128+
className?: 'className,
129+
children: 'children,
130+
}
131+
132+
@react.component
133+
let make = ({?className, children, _}: props<'className, 'children>, ref) =>
134+
ReactDOM.jsxs(
135+
"div",
136+
{
137+
children: React.array([
138+
ReactDOM.jsx(
139+
"input",
140+
{
141+
type_: "text",
142+
?className,
143+
ref: ?Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef),
144+
},
145+
),
146+
children,
147+
]),
148+
},
149+
)
150+
let make = React.forwardRef({
151+
let \"ForwardRef$V4A$FancyInput" = (props: props<_>, ref) => make(props, ref)
152+
\"ForwardRef$V4A$FancyInput"
153+
})
125154
}
155+
type props = {key?: string}
126156

127157
@react.component
128-
let make = ({?className, children, _}: props<'className, 'children>, ref) =>
129-
ReactDOM.jsxs(
158+
let make = (_: props) => {
159+
let input = React.useRef(Js.Nullable.null)
160+
161+
ReactDOM.jsx(
130162
"div",
131163
{
132-
children: React.array([
133-
ReactDOM.jsx(
134-
"input",
135-
{
136-
type_: "text",
137-
?className,
138-
ref: ?Js.Nullable.toOption(ref)->Belt.Option.map(ReactDOM.Ref.domRef),
139-
},
140-
),
141-
children,
142-
]),
164+
children: React.jsx(
165+
FancyInput.make,
166+
{ref: input, children: {React.string("Click to focus")}},
167+
),
143168
},
144169
)
145-
let make = React.forwardRef({
146-
let \"ForwardRef$FancyInput" = (props: props<_>, ref) => make(props, ref)
147-
\"ForwardRef$FancyInput"
148-
})
149-
}
150-
type props = {key?: string}
151-
152-
@react.component
153-
let make = (_: props) => {
154-
let input = React.useRef(Js.Nullable.null)
155-
156-
ReactDOM.jsx(
157-
"div",
158-
{
159-
children: React.jsx(
160-
FancyInput.make,
161-
{ref: input, children: {React.string("Click to focus")}},
162-
),
163-
},
164-
)
165-
}
166-
let make = {
167-
let \"ForwardRef" = props => make(props)
168-
\"ForwardRef"
170+
}
171+
let make = {
172+
let \"ForwardRef$V4A" = props => make(props)
173+
\"ForwardRef$V4A"
174+
}
169175
}

0 commit comments

Comments
 (0)