Skip to content

Commit b0d385a

Browse files
committed
clean up extract jsx in bsb config
1 parent e77774f commit b0d385a

File tree

2 files changed

+22
-46
lines changed

2 files changed

+22
-46
lines changed

jscomp/bsb/bsb_config_parse.ml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,62 +145,52 @@ let extract_reason_react_jsx (map : json_map) =
145145
|> ignore;
146146
!default
147147

148-
let extract_jsx_version (map : json_map) =
149-
let default : Bsb_config_types.jsx_version option ref = ref None in
148+
let extract_jsx (map : json_map) =
149+
let version : Bsb_config_types.jsx_version option ref = ref None in
150+
let module_ : Bsb_config_types.jsx_module option ref = ref None in
151+
let mode : Bsb_config_types.jsx_mode option ref = ref None in
150152
map
151153
|? ( Bsb_build_schemas.jsx,
152154
`Obj
153155
(fun m ->
154156
match m.?(Bsb_build_schemas.jsx_version) with
155157
| Some (Flo { loc; flo }) -> (
156158
match flo with
157-
| "3" -> default := Some Jsx_v3
158-
| "4" -> default := Some Jsx_v4
159+
| "3" -> version := Some Jsx_v3
160+
| "4" -> version := Some Jsx_v4
159161
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx-version %s" flo
160162
)
161163
| Some x ->
162164
Bsb_exception.config_error x
163165
"Unexpected input (expect a version number) for jsx-version"
164166
| None -> ()) )
165-
|> ignore;
166-
!default
167-
168-
let extract_jsx_module (map : json_map) =
169-
let default : Bsb_config_types.jsx_module option ref = ref None in
170-
map
171167
|? ( Bsb_build_schemas.jsx,
172168
`Obj
173169
(fun m ->
174170
match m.?(Bsb_build_schemas.jsx_module) with
175171
| Some (Str { loc; str }) -> (
176172
match str with
177-
| "react" -> default := Some React
173+
| "react" -> module_ := Some React
178174
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx-module %s" str)
179175
| Some x ->
180176
Bsb_exception.config_error x
181177
"Unexpected input (jsx module name) for jsx-mode"
182178
| None -> ()) )
183-
|> ignore;
184-
!default
185-
186-
let extract_jsx_mode (map : json_map) =
187-
let default : Bsb_config_types.jsx_mode option ref = ref None in
188-
map
189179
|? ( Bsb_build_schemas.jsx,
190180
`Obj
191181
(fun m ->
192182
match m.?(Bsb_build_schemas.jsx_mode) with
193183
| Some (Str { loc; str }) -> (
194184
match str with
195-
| "classic" -> default := Some Classic
196-
| "automatic" -> default := Some Automatic
185+
| "classic" -> mode := Some Classic
186+
| "automatic" -> mode := Some Automatic
197187
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx-mode %s" str)
198188
| Some x ->
199189
Bsb_exception.config_error x
200190
"Unexpected input (expect classic or automatic) for jsx-mode"
201191
| None -> ()) )
202192
|> ignore;
203-
!default
193+
(!version, !module_, !mode)
204194

205195
let extract_warning (map : json_map) =
206196
match map.?(Bsb_build_schemas.warnings) with
@@ -349,9 +339,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
349339
.path)
350340
in
351341
let reason_react_jsx = extract_reason_react_jsx map in
352-
let jsx_version = extract_jsx_version map in
353-
let jsx_module = extract_jsx_module map in
354-
let jsx_mode = extract_jsx_mode map in
342+
let jsx_version, jsx_module, jsx_mode = extract_jsx map in
355343
let bs_dependencies =
356344
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies
357345
in

lib/4.06.1/rescript.ml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10388,62 +10388,52 @@ let extract_reason_react_jsx (map : json_map) =
1038810388
|> ignore;
1038910389
!default
1039010390

10391-
let extract_jsx_version (map : json_map) =
10392-
let default : Bsb_config_types.jsx_version option ref = ref None in
10391+
let extract_jsx (map : json_map) =
10392+
let version : Bsb_config_types.jsx_version option ref = ref None in
10393+
let module_ : Bsb_config_types.jsx_module option ref = ref None in
10394+
let mode : Bsb_config_types.jsx_mode option ref = ref None in
1039310395
map
1039410396
|? ( Bsb_build_schemas.jsx,
1039510397
`Obj
1039610398
(fun m ->
1039710399
match m.?(Bsb_build_schemas.jsx_version) with
1039810400
| Some (Flo { loc; flo }) -> (
1039910401
match flo with
10400-
| "3" -> default := Some Jsx_v3
10401-
| "4" -> default := Some Jsx_v4
10402+
| "3" -> version := Some Jsx_v3
10403+
| "4" -> version := Some Jsx_v4
1040210404
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx-version %s" flo
1040310405
)
1040410406
| Some x ->
1040510407
Bsb_exception.config_error x
1040610408
"Unexpected input (expect a version number) for jsx-version"
1040710409
| None -> ()) )
10408-
|> ignore;
10409-
!default
10410-
10411-
let extract_jsx_module (map : json_map) =
10412-
let default : Bsb_config_types.jsx_module option ref = ref None in
10413-
map
1041410410
|? ( Bsb_build_schemas.jsx,
1041510411
`Obj
1041610412
(fun m ->
1041710413
match m.?(Bsb_build_schemas.jsx_module) with
1041810414
| Some (Str { loc; str }) -> (
1041910415
match str with
10420-
| "react" -> default := Some React
10416+
| "react" -> module_ := Some React
1042110417
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx-module %s" str)
1042210418
| Some x ->
1042310419
Bsb_exception.config_error x
1042410420
"Unexpected input (jsx module name) for jsx-mode"
1042510421
| None -> ()) )
10426-
|> ignore;
10427-
!default
10428-
10429-
let extract_jsx_mode (map : json_map) =
10430-
let default : Bsb_config_types.jsx_mode option ref = ref None in
10431-
map
1043210422
|? ( Bsb_build_schemas.jsx,
1043310423
`Obj
1043410424
(fun m ->
1043510425
match m.?(Bsb_build_schemas.jsx_mode) with
1043610426
| Some (Str { loc; str }) -> (
1043710427
match str with
10438-
| "classic" -> default := Some Classic
10439-
| "automatic" -> default := Some Automatic
10428+
| "classic" -> mode := Some Classic
10429+
| "automatic" -> mode := Some Automatic
1044010430
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx-mode %s" str)
1044110431
| Some x ->
1044210432
Bsb_exception.config_error x
1044310433
"Unexpected input (expect classic or automatic) for jsx-mode"
1044410434
| None -> ()) )
1044510435
|> ignore;
10446-
!default
10436+
(!version, !module_, !mode)
1044710437

1044810438
let extract_warning (map : json_map) =
1044910439
match map.?(Bsb_build_schemas.warnings) with
@@ -10592,9 +10582,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
1059210582
.path)
1059310583
in
1059410584
let reason_react_jsx = extract_reason_react_jsx map in
10595-
let jsx_version = extract_jsx_version map in
10596-
let jsx_module = extract_jsx_module map in
10597-
let jsx_mode = extract_jsx_mode map in
10585+
let jsx_version, jsx_module, jsx_mode = extract_jsx map in
1059810586
let bs_dependencies =
1059910587
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies
1060010588
in

0 commit comments

Comments
 (0)