@@ -17,7 +17,6 @@ use swc_ecma_transforms::{
1717 class_fields_use_set:: class_fields_use_set,
1818 es2015:: { self , generator:: generator} ,
1919 es2016, es2017, es2018, es2019, es2020, es2022, es3,
20- regexp:: { self , regexp} ,
2120 } ,
2221 Assumptions ,
2322} ;
5150 C : Comments + Clone ,
5251{
5352 let pass = noop_pass ( ) ;
53+ let mut options = swc_ecma_transformer:: Options :: default ( ) ;
5454
5555 macro_rules! add {
5656 ( $prev: expr, $feature: ident, $pass: expr) => { {
@@ -114,39 +114,20 @@ where
114114 ) ,
115115 ) ;
116116
117- let pass = {
118- let enable_dot_all_regex = !caniuse ( Feature :: DotAllRegex ) ;
119- let enable_named_capturing_groups_regex = !caniuse ( Feature :: NamedCapturingGroupsRegex ) ;
120- let enable_sticky_regex = !caniuse ( Feature :: StickyRegex ) ;
121- let enable_unicode_property_regex = !caniuse ( Feature :: UnicodePropertyRegex ) ;
122- let enable_unicode_regex = !caniuse ( Feature :: UnicodeRegex ) ;
123- let enable_unicode_sets_regex = !caniuse ( Feature :: UnicodeSetsRegex ) ;
124-
125- let enable = enable_dot_all_regex
126- || enable_named_capturing_groups_regex
127- || enable_sticky_regex
128- || enable_unicode_property_regex
129- || enable_unicode_regex;
130-
131- (
132- pass,
133- Optional :: new (
134- regexp ( regexp:: Config {
135- dot_all_regex : enable_dot_all_regex,
136- // TODO: add Feature:HasIndicesRegex
137- has_indices : false ,
138- // TODO: add Feature::LookbehindAssertion
139- lookbehind_assertion : false ,
140- named_capturing_groups_regex : enable_named_capturing_groups_regex,
141- sticky_regex : enable_sticky_regex,
142- unicode_property_regex : enable_unicode_property_regex,
143- unicode_regex : enable_unicode_regex,
144- unicode_sets_regex : enable_unicode_sets_regex,
145- } ) ,
146- enable,
147- ) ,
148- )
149- } ;
117+ {
118+ let t = & mut options. env . regexp ;
119+
120+ t. dot_all_regex = !caniuse ( Feature :: DotAllRegex ) ;
121+ t. named_capturing_groups_regex = !caniuse ( Feature :: NamedCapturingGroupsRegex ) ;
122+ t. sticky_regex = !caniuse ( Feature :: StickyRegex ) ;
123+ t. unicode_property_regex = !caniuse ( Feature :: UnicodePropertyRegex ) ;
124+ t. unicode_regex = !caniuse ( Feature :: UnicodeRegex ) ;
125+ t. unicode_sets_regex = !caniuse ( Feature :: UnicodeSetsRegex ) ;
126+ // TODO: add Feature:HasIndicesRegex
127+ t. has_indices = false ;
128+ // TODO: add Feature::LookbehindAssertion
129+ t. lookbehind_assertion = false ;
130+ }
150131
151132 // Proposals
152133
@@ -344,11 +325,13 @@ where
344325 bugfixes:: template_literal_caching( )
345326 ) ;
346327
347- add ! (
328+ let pass = add ! (
348329 pass,
349330 BugfixSafariIdDestructuringCollisionInFunctionExpression ,
350331 bugfixes:: safari_id_destructuring_collision_in_function_expression( )
351- )
332+ ) ;
333+
334+ ( pass, options. into_pass ( ) )
352335}
353336
354337pub fn transform_from_env < C > (
0 commit comments