@@ -96,6 +96,8 @@ impl From<ES2015BindingOptions> for ES2015Options {
96
96
pub struct TransformOptions {
97
97
#[ napi( ts_type = "'script' | 'module' | 'unambiguous' | undefined" ) ]
98
98
pub source_type : Option < String > ,
99
+ /// Force jsx parsing,
100
+ pub jsx : Option < bool > ,
99
101
pub typescript : Option < TypeScriptBindingOptions > ,
100
102
pub react : Option < ReactBindingOptions > ,
101
103
pub es2015 : Option < ES2015BindingOptions > ,
@@ -145,11 +147,19 @@ pub fn transform(
145
147
let sourcemap = options. as_ref ( ) . is_some_and ( |x| x. sourcemap . unwrap_or_default ( ) ) ;
146
148
let mut errors = vec ! [ ] ;
147
149
148
- let source_type = SourceType :: from_path ( & filename) . unwrap_or_default ( ) ;
149
- let source_type = match options. as_ref ( ) . and_then ( |options| options. source_type . as_deref ( ) ) {
150
- Some ( "script" ) => source_type. with_script ( true ) ,
151
- Some ( "module" ) => source_type. with_module ( true ) ,
152
- _ => source_type,
150
+ let source_type = {
151
+ let mut source_type = SourceType :: from_path ( & filename) . unwrap_or_default ( ) ;
152
+ // Force `script` or `module`
153
+ match options. as_ref ( ) . and_then ( |options| options. source_type . as_deref ( ) ) {
154
+ Some ( "script" ) => source_type = source_type. with_script ( true ) ,
155
+ Some ( "module" ) => source_type = source_type. with_module ( true ) ,
156
+ _ => { }
157
+ }
158
+ // Force `jsx`
159
+ if let Some ( jsx) = options. as_ref ( ) . and_then ( |options| options. jsx . as_ref ( ) ) {
160
+ source_type = source_type. with_jsx ( * jsx) ;
161
+ }
162
+ source_type
153
163
} ;
154
164
155
165
let allocator = Allocator :: default ( ) ;
0 commit comments