@@ -8,7 +8,10 @@ use std::{
88use anyhow:: { Context , Error } ;
99use once_cell:: sync:: Lazy ;
1010use swc:: {
11- config:: { Config , JsMinifyOptions , JscConfig , ModuleConfig , Options , SourceMapsConfig } ,
11+ config:: {
12+ Config , JsMinifyOptions , JscConfig , ModuleConfig , Options , SourceMapsConfig ,
13+ TransformConfig ,
14+ } ,
1215 try_with_handler, BoolOrDataConfig , Compiler , HandlerOpts ,
1316} ;
1417use swc_common:: { errors:: ColorConfig , SourceMap , GLOBALS } ;
@@ -113,10 +116,7 @@ fn init_helpers() -> Arc<PathBuf> {
113116}
114117
115118fn create_matrix ( entry : & Path ) -> Vec < Options > {
116- // use_define_for_class_fields: false
117- // force to use [[Set]] instead of [[Define]]
118- // EsVersion should be lower than EsVersion::Es2022
119- let force_set_class_field = entry
119+ let use_define_for_class_fields = entry
120120 . parent ( )
121121 . map ( |parent| parent. join ( ".swcrc" ) )
122122 . and_then ( |path| fs:: read_to_string ( path) . ok ( ) )
@@ -133,8 +133,8 @@ fn create_matrix(entry: &Path) -> Vec<Options> {
133133 } )
134134 . and_then ( |content| serde_json:: from_value :: < Config > ( content) . ok ( ) )
135135 . and_then ( |config| config. jsc . transform . into_inner ( ) )
136- . map ( |c| c. use_define_for_class_fields == false . into ( ) )
137- . unwrap_or ( false ) ;
136+ . map ( |c| c. use_define_for_class_fields )
137+ . unwrap_or_default ( ) ;
138138
139139 [
140140 EsVersion :: Es2022 ,
@@ -148,7 +148,6 @@ fn create_matrix(entry: &Path) -> Vec<Options> {
148148 EsVersion :: Es5 ,
149149 ]
150150 . into_iter ( )
151- . filter ( |e| !force_set_class_field || e < & EsVersion :: Es2022 )
152151 . matrix ( || {
153152 let default_es = Syntax :: Es ( EsConfig {
154153 ..Default :: default ( )
@@ -177,7 +176,11 @@ fn create_matrix(entry: &Path) -> Vec<Options> {
177176 config : Config {
178177 jsc : JscConfig {
179178 syntax : Some ( syntax) ,
180- transform : None . into ( ) ,
179+ transform : Some ( TransformConfig {
180+ use_define_for_class_fields,
181+ ..Default :: default ( )
182+ } )
183+ . into ( ) ,
181184 // true, false
182185 external_helpers : ( !external_helpers) . into ( ) ,
183186 target : Some ( target) ,
@@ -307,11 +310,19 @@ fn get_expected_stdout(input: &Path) -> Result<String, Error> {
307310 & Options {
308311 config : Config {
309312 jsc : JscConfig {
310- target : Some ( EsVersion :: Es2021 ) ,
313+ target : Some ( EsVersion :: Es2022 ) ,
311314 syntax : Some ( Syntax :: Typescript ( TsConfig {
312315 decorators : true ,
313316 ..Default :: default ( )
314317 } ) ) ,
318+ transform : Some ( TransformConfig {
319+ use_define_for_class_fields : ( !input
320+ . to_string_lossy ( )
321+ . contains ( "set_public_class_fields" ) )
322+ . into ( ) ,
323+ ..Default :: default ( )
324+ } )
325+ . into ( ) ,
315326 ..Default :: default ( )
316327 } ,
317328 module : match input. extension ( ) {
0 commit comments