From 085df0dae8004ef140fc5694212477c6ddd16d39 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 27 Oct 2021 07:11:26 +0900 Subject: [PATCH] Merge impl --- src/config/mod.rs | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index a85413759d52..43fa60c2e136 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1361,7 +1361,48 @@ impl Merge for bool { impl Merge for Syntax { fn merge(&mut self, from: &Self) { - *self = *from; + match (&mut *self, from) { + (Syntax::Es(a), Syntax::Es(b)) => { + a.merge(b); + } + (Syntax::Typescript(a), Syntax::Typescript(b)) => { + a.merge(b); + } + _ => { + *self = *from; + } + } + } +} + +impl Merge for swc_ecma_parser::EsConfig { + fn merge(&mut self, from: &Self) { + self.jsx |= from.jsx; + self.class_private_props |= from.class_private_props; + self.class_private_methods |= from.class_private_methods; + self.class_props |= from.class_props; + self.fn_bind |= from.fn_bind; + self.decorators |= from.decorators; + self.decorators_before_export |= from.decorators_before_export; + self.export_default_from |= from.export_default_from; + self.export_namespace_from |= from.export_namespace_from; + self.dynamic_import |= from.dynamic_import; + self.nullish_coalescing |= from.nullish_coalescing; + self.optional_chaining |= from.optional_chaining; + self.import_meta |= from.import_meta; + self.top_level_await |= from.top_level_await; + self.import_assertions |= from.import_assertions; + self.static_blocks |= from.static_blocks; + self.private_in_object |= from.private_in_object; + } +} + +impl Merge for swc_ecma_parser::TsConfig { + fn merge(&mut self, from: &Self) { + self.tsx |= from.tsx; + self.decorators |= from.decorators; + self.dynamic_import |= from.dynamic_import; + self.import_assertions |= from.import_assertions; } }