@@ -184,6 +184,7 @@ pub struct JsxSpecs {
184184 pub mode : Option < JsxMode > ,
185185 #[ serde( rename = "v3-dependencies" ) ]
186186 pub v3_dependencies : Option < Vec < String > > ,
187+ pub preserve : Option < bool > ,
187188}
188189
189190/// We do not care about the internal structure because the gentype config is loaded by bsc.
@@ -434,6 +435,16 @@ impl Config {
434435 }
435436 }
436437
438+ pub fn get_jsx_preserve_args ( & self ) -> Vec < String > {
439+ match self . jsx . to_owned ( ) {
440+ Some ( jsx) => match jsx. preserve {
441+ Some ( true ) => vec ! [ "-bs-jsx-preserve" . to_string( ) ] ,
442+ _ => vec ! [ ] ,
443+ } ,
444+ _ => vec ! [ ] ,
445+ }
446+ }
447+
437448 pub fn get_uncurried_args ( & self , version : & str ) -> Vec < String > {
438449 match check_if_rescript11_or_higher ( version) {
439450 Ok ( true ) => match self . uncurried . to_owned ( ) {
@@ -614,6 +625,35 @@ mod tests {
614625 module: Some ( JsxModule :: Other ( String :: from( "Voby.JSX" ) ) ) ,
615626 mode: None ,
616627 v3_dependencies: None ,
628+ preserve: None ,
629+ } ,
630+ ) ;
631+ }
632+
633+ #[ test]
634+ fn test_jsx_preserve ( ) {
635+ let json = r#"
636+ {
637+ "name": "my-monorepo",
638+ "sources": [ { "dir": "src/", "subdirs": true } ],
639+ "package-specs": [ { "module": "es6", "in-source": true } ],
640+ "suffix": ".mjs",
641+ "pinned-dependencies": [ "@teamwalnut/app" ],
642+ "bs-dependencies": [ "@teamwalnut/app" ],
643+ "jsx": { "version": 4, "preserve": true }
644+ }
645+ "# ;
646+
647+ let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
648+ assert ! ( config. jsx. is_some( ) ) ;
649+ assert_eq ! (
650+ config. jsx. unwrap( ) ,
651+ JsxSpecs {
652+ version: Some ( 4 ) ,
653+ module: None ,
654+ mode: None ,
655+ v3_dependencies: None ,
656+ preserve: Some ( true ) ,
617657 } ,
618658 ) ;
619659 }
0 commit comments