@@ -140,21 +140,22 @@ pub enum NamespaceConfig {
140
140
String ( String ) ,
141
141
}
142
142
143
- #[ derive( Deserialize , Debug , Clone ) ]
143
+ #[ derive( Deserialize , Debug , Clone , Eq , PartialEq ) ]
144
+ #[ serde( rename_all = "camelCase" ) ]
144
145
pub enum JsxMode {
145
- #[ serde( rename = "classic" ) ]
146
146
Classic ,
147
- #[ serde( rename = "automatic" ) ]
148
147
Automatic ,
149
148
}
150
149
151
- #[ derive( Deserialize , Debug , Clone ) ]
150
+ #[ derive( Deserialize , Debug , Clone , Eq , PartialEq ) ]
151
+ #[ serde( rename_all = "camelCase" ) ]
152
+ #[ serde( untagged) ]
152
153
pub enum JsxModule {
153
- #[ serde( rename = "react" ) ]
154
154
React ,
155
+ Other ( String ) ,
155
156
}
156
157
157
- #[ derive( Deserialize , Debug , Clone ) ]
158
+ #[ derive( Deserialize , Debug , Clone , Eq , PartialEq ) ]
158
159
pub struct JsxSpecs {
159
160
pub version : Option < i32 > ,
160
161
pub module : Option < JsxModule > ,
@@ -376,6 +377,9 @@ impl Config {
376
377
Some ( JsxModule :: React ) => {
377
378
vec ! [ "-bs-jsx-module" . to_string( ) , "react" . to_string( ) ]
378
379
}
380
+ Some ( JsxModule :: Other ( module) ) => {
381
+ vec ! [ "-bs-jsx-module" . to_string( ) , module]
382
+ }
379
383
None => vec ! [ ] ,
380
384
} ,
381
385
_ => vec ! [ ] ,
@@ -476,7 +480,7 @@ mod tests {
476
480
"# ;
477
481
478
482
let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
479
- if let OneOrMore :: Single ( source) = config. sources {
483
+ if let Some ( OneOrMore :: Single ( source) ) = config. sources {
480
484
let source = source. to_qualified_without_children ( None ) ;
481
485
assert_eq ! ( source. type_, Some ( String :: from( "dev" ) ) ) ;
482
486
} else {
@@ -507,6 +511,35 @@ mod tests {
507
511
assert_eq ! ( config. get_gentype_arg( ) , vec![ "-bs-gentype" . to_string( ) ] ) ;
508
512
}
509
513
514
+ #[ test]
515
+ fn test_other_jsx_module ( ) {
516
+ let json = r#"
517
+ {
518
+ "name": "my-monorepo",
519
+ "sources": [ { "dir": "src/", "subdirs": true } ],
520
+ "package-specs": [ { "module": "es6", "in-source": true } ],
521
+ "suffix": ".mjs",
522
+ "pinned-dependencies": [ "@teamwalnut/app" ],
523
+ "bs-dependencies": [ "@teamwalnut/app" ],
524
+ "jsx": {
525
+ "module": "Voby.JSX"
526
+ }
527
+ }
528
+ "# ;
529
+
530
+ let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
531
+ assert ! ( config. jsx. is_some( ) ) ;
532
+ assert_eq ! (
533
+ config. jsx. unwrap( ) ,
534
+ JsxSpecs {
535
+ version: None ,
536
+ module: Some ( JsxModule :: Other ( String :: from( "Voby.JSX" ) ) ) ,
537
+ mode: None ,
538
+ v3_dependencies: None ,
539
+ } ,
540
+ ) ;
541
+ }
542
+
510
543
#[ test]
511
544
fn test_check_if_rescript11_or_higher ( ) {
512
545
assert_eq ! ( check_if_rescript11_or_higher( "11.0.0" ) , Ok ( true ) ) ;
0 commit comments