From 6ac4a23aa2fdf3854f23760cec70b36249df4cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 10 May 2022 05:15:15 +0900 Subject: [PATCH] feat(es/hygiene): Drop syntax context (#4594) --- crates/swc_ecma_transforms_base/src/hygiene/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/swc_ecma_transforms_base/src/hygiene/mod.rs b/crates/swc_ecma_transforms_base/src/hygiene/mod.rs index 927498eea88..88023fffae5 100644 --- a/crates/swc_ecma_transforms_base/src/hygiene/mod.rs +++ b/crates/swc_ecma_transforms_base/src/hygiene/mod.rs @@ -163,7 +163,17 @@ pub fn hygiene() -> impl Fold + VisitMut + 'static { /// /// At third phase, we rename all identifiers in the queue. pub fn hygiene_with_config(config: Config) -> impl 'static + Fold + VisitMut { - as_folder(chain!(unique_scope(), Hygiene { config })) + as_folder(chain!(unique_scope(), Hygiene { config }, HygieneRemover)) +} + +struct HygieneRemover; + +impl VisitMut for HygieneRemover { + noop_visit_mut_type!(); + + fn visit_mut_ident(&mut self, i: &mut Ident) { + i.span.ctxt = Default::default(); + } } #[derive(Debug, Default)]