@@ -120,7 +120,8 @@ impl SWC {
120
120
let is_dev = resolver. borrow ( ) . is_dev ;
121
121
let is_ts = extname == "ts" || extname == "mts" || extname == "tsx" ;
122
122
let jsxt = options. jsx . as_deref ( ) . unwrap_or ( "classic" ) ;
123
- let is_jsx = jsxt != "preserve" && ( extname == "jsx" || extname == "tsx" ) ;
123
+ let jsx_preserve = jsxt == "preserve" ;
124
+ let is_jsx = extname == "jsx" || extname == "tsx" ;
124
125
let react_options = if jsxt == "automatic" {
125
126
let mut resolver = resolver. borrow_mut ( ) ;
126
127
let import_source = options. jsx_import_source . as_deref ( ) . unwrap_or ( "react" ) ;
@@ -151,7 +152,7 @@ impl SWC {
151
152
let assumptions = Assumptions :: all ( ) ;
152
153
let passes = chain ! (
153
154
swc_ecma_transforms:: resolver( unresolved_mark, top_level_mark, is_ts) ,
154
- Optional :: new( react:: jsx_src( is_dev, self . source_map. clone( ) ) , is_jsx) ,
155
+ Optional :: new( react:: jsx_src( is_dev, self . source_map. clone( ) ) , is_jsx && is_dev ) ,
155
156
resolve_fold( resolver. clone( ) , options. strip_data_export, false ) ,
156
157
decorators:: decorators( decorators:: Config {
157
158
legacy: true ,
@@ -250,13 +251,14 @@ impl SWC {
250
251
self . source_map. clone( ) ,
251
252
Some ( & self . comments) ,
252
253
react:: Options {
254
+ next: Some ( true ) ,
253
255
use_builtins: Some ( true ) ,
254
256
development: Some ( is_dev) ,
255
257
..react_options
256
258
} ,
257
259
top_level_mark
258
260
) ,
259
- is_jsx
261
+ is_jsx && !jsx_preserve
260
262
) ,
261
263
Optional :: new( hmr( resolver. clone( ) ) , is_dev && !specifier_is_remote) ,
262
264
dce:: dce(
@@ -278,7 +280,11 @@ impl SWC {
278
280
} ) ,
279
281
options. minify. is_some( )
280
282
) ,
281
- hygiene( ) ,
283
+ hygiene:: hygiene_with_config( hygiene:: Config {
284
+ keep_class_names: true ,
285
+ top_level_mark: top_level_mark,
286
+ ..Default :: default ( )
287
+ } ) ,
282
288
fixer( Some ( & self . comments) ) ,
283
289
) ;
284
290
0 commit comments