From 3590ea22779fa3ca57fc9eab55cd203f9fb23f29 Mon Sep 17 00:00:00 2001 From: Austaras Date: Sun, 13 Mar 2022 00:14:03 +0800 Subject: [PATCH] fix(es): Merge `jsc.loose` and `jsc.assumptions` (#3990) --- crates/swc/src/config/mod.rs | 32 ++++++++++++++++++- .../swc/tests/fixture/issue-2216/input/.swcrc | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index 217b8272a76..0251e8bed35 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -1572,10 +1572,12 @@ impl Merge for swc_ecma_preset_env::Config { impl Merge for JscConfig { fn merge(&mut self, from: &Self) { + self.assumptions.merge(&from.assumptions); self.syntax.merge(&from.syntax); self.transform.merge(&from.transform); - self.target.merge(&from.target); self.external_helpers.merge(&from.external_helpers); + self.target.merge(&from.target); + self.loose.merge(&from.loose); self.keep_class_names.merge(&from.keep_class_names); self.paths.merge(&from.paths); self.minify.merge(&from.minify); @@ -1673,6 +1675,34 @@ impl Merge for swc_ecma_parser::TsConfig { } } +impl Merge for Assumptions { + fn merge(&mut self, from: &Self) { + self.array_like_is_iterable |= from.array_like_is_iterable; + self.constant_reexports |= from.constant_reexports; + self.constant_super |= from.constant_super; + self.enumerable_module_meta |= from.enumerable_module_meta; + self.ignore_function_length |= from.ignore_function_length; + self.ignore_function_name |= from.ignore_function_name; + self.ignore_to_primitive_hint |= from.ignore_to_primitive_hint; + self.iterable_is_array |= from.iterable_is_array; + self.mutable_template_object |= from.mutable_template_object; + self.no_class_calls |= from.no_class_calls; + self.no_document_all |= from.no_document_all; + self.no_incomplete_ns_import_detection |= from.no_incomplete_ns_import_detection; + self.no_new_arrows |= from.no_new_arrows; + self.object_rest_no_symbols |= from.object_rest_no_symbols; + self.private_fields_as_properties |= from.private_fields_as_properties; + self.pure_getters |= from.pure_getters; + self.set_class_methods |= from.set_class_methods; + self.set_computed_properties |= from.set_computed_properties; + self.set_public_class_fields |= from.set_public_class_fields; + self.set_spread_properties |= from.set_spread_properties; + self.skip_for_of_iterator_closing |= from.skip_for_of_iterator_closing; + self.super_is_callable_constructor |= from.super_is_callable_constructor; + self.ts_enum_is_readonly |= from.ts_enum_is_readonly; + } +} + impl Merge for TransformConfig { fn merge(&mut self, from: &Self) { self.optimizer.merge(&from.optimizer); diff --git a/crates/swc/tests/fixture/issue-2216/input/.swcrc b/crates/swc/tests/fixture/issue-2216/input/.swcrc index f4f413853cd..ff60ff74599 100644 --- a/crates/swc/tests/fixture/issue-2216/input/.swcrc +++ b/crates/swc/tests/fixture/issue-2216/input/.swcrc @@ -5,4 +5,4 @@ }, "loose": true } -} \ No newline at end of file +}