diff --git a/crates/swc_ecma_utils/src/lib.rs b/crates/swc_ecma_utils/src/lib.rs index e7be5085ec09..9dcec47281d4 100644 --- a/crates/swc_ecma_utils/src/lib.rs +++ b/crates/swc_ecma_utils/src/lib.rs @@ -2292,6 +2292,27 @@ impl VisitMut for IdentReplacer<'_> { visit_mut_obj_and_computed!(); + fn visit_mut_prop(&mut self, node: &mut Prop) { + match node { + Prop::Shorthand(i) => { + let cloned = i.clone(); + i.visit_mut_with(self); + if i.sym != cloned.sym || i.span.ctxt != cloned.span.ctxt { + *node = Prop::KeyValue(KeyValueProp { + key: PropName::Ident(Ident::new( + cloned.sym, + cloned.span.with_ctxt(SyntaxContext::empty()), + )), + value: Box::new(Expr::Ident(i.clone())), + }); + } + } + _ => { + node.visit_mut_children_with(self); + } + } + } + fn visit_mut_ident(&mut self, node: &mut Ident) { if node.sym == self.from.0 && node.span.ctxt == self.from.1 { *node = self.to.clone();