Skip to content

Commit 2fdb010

Browse files
committed
fix compilation
1 parent 51a0de9 commit 2fdb010

File tree

2 files changed

+3
-55
lines changed

2 files changed

+3
-55
lines changed

crates/swc_ecma_preset_env/src/lib.rs

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde::Deserialize;
1111
use swc_atoms::{atom, Atom};
1212
use swc_common::{comments::Comments, pass::Optional, FromVariant, Mark, SyntaxContext, DUMMY_SP};
1313
use swc_ecma_ast::*;
14-
use swc_ecma_compiler::compat::{CompatCompiler, HelperLoaderMode, TransformOptions};
14+
use swc_ecma_compiler::{HelperLoaderMode, TransformOptions, Transformer};
1515
use swc_ecma_transforms::{
1616
compat::{
1717
bugfixes,
@@ -69,44 +69,6 @@ where
6969
}};
7070
}
7171

72-
macro_rules! add_compiler {
73-
($($feature:ident)|*) => {{
74-
let mut feature = swc_ecma_compiler::Features::empty();
75-
$(
76-
{
77-
let f = transform_data::Feature::$feature;
78-
let enable = !caniuse(f);
79-
80-
if debug {
81-
println!("{}: {:?}", f.as_str(), enable);
82-
}
83-
84-
if enable {
85-
feature |= swc_ecma_compiler::Features::from(f);
86-
}
87-
}
88-
)*
89-
feature
90-
}};
91-
(| $($feature:ident)|*) => {{
92-
add_compiler!($($feature)|*)
93-
}};
94-
($prev:expr, $($feature:ident)|*) => {{
95-
let feature = add_compiler!($($feature)|*);
96-
(
97-
$prev,
98-
swc_ecma_compiler::Compiler::new(swc_ecma_compiler::Config {
99-
includes: feature,
100-
assumptions,
101-
..Default::default()
102-
}),
103-
)
104-
}};
105-
($prev:expr, | $($feature:ident)|*) => {{
106-
add_compiler!($prev, $($feature)|*)
107-
}};
108-
}
109-
11072
compiler_options.assumptions.set_public_class_fields = assumptions.set_public_class_fields;
11173

11274
{
@@ -151,7 +113,7 @@ where
151113
)
152114
);
153115

154-
let pass = add_compiler!(pass, /* ES2022 */ PrivatePropertyInObject);
116+
// let pass = add_compiler!(pass, /* ES2022 */ PrivatePropertyInObject);
155117

156118
if !caniuse(Feature::LogicalAssignmentOperators) {
157119
compiler_options.env.es2021.logical_assignment_operators = true;
@@ -319,7 +281,7 @@ where
319281
bugfixes::safari_id_destructuring_collision_in_function_expression()
320282
);
321283

322-
(visit_mut_pass(CompatCompiler::new(&compiler_options)), pass)
284+
(Transformer::new("".as_ref(), &compiler_options), pass)
323285
}
324286

325287
pub fn transform_from_env<C>(

crates/swc_ecma_preset_env/src/transform_data.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,6 @@ pub enum Feature {
211211
RegexpModifiers,
212212
}
213213

214-
// [TODO]: Unify Feature flag
215-
impl From<Feature> for swc_ecma_compiler::Features {
216-
fn from(value: Feature) -> Self {
217-
match value {
218-
Feature::ClassStaticBlock => Self::STATIC_BLOCKS,
219-
Feature::OptionalChaining => Self::OPTIONAL_CHAINING,
220-
Feature::PrivatePropertyInObject => Self::PRIVATE_IN_OBJECT,
221-
Feature::LogicalAssignmentOperators => Self::LOGICAL_ASSIGNMENTS,
222-
Feature::ExportNamespaceFrom => Self::EXPORT_NAMESPACE_FROM,
223-
_ => Self::empty(),
224-
}
225-
}
226-
}
227-
228214
pub(crate) static FEATURES: Lazy<FxHashMap<Feature, BrowserData<Option<Version>>>> =
229215
Lazy::new(|| {
230216
let map: FxHashMap<Feature, BrowserData<Option<String>>> =

0 commit comments

Comments
 (0)