From 95eb147742ea1aa207845807a306847afc859702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 12 Oct 2023 13:04:10 +0900 Subject: [PATCH] refactor(es/preset-env): Rename parameter to avoid confusion (#8106) **Related issue:** - Closes #8103 --- crates/swc_ecma_preset_env/src/lib.rs | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/crates/swc_ecma_preset_env/src/lib.rs b/crates/swc_ecma_preset_env/src/lib.rs index 65c5dd3e2350..b715b4f231a9 100644 --- a/crates/swc_ecma_preset_env/src/lib.rs +++ b/crates/swc_ecma_preset_env/src/lib.rs @@ -36,7 +36,7 @@ mod regenerator; mod transform_data; pub fn preset_env( - global_mark: Mark, + unresolved_mark: Mark, comments: Option, c: Config, assumptions: Assumptions, @@ -178,7 +178,7 @@ where no_document_all: loose || assumptions.no_document_all, pure_getter: loose || assumptions.pure_getters }, - global_mark + unresolved_mark ) ); @@ -206,7 +206,7 @@ where ignore_function_length: loose || assumptions.ignore_function_length, }, comments.clone(), - global_mark + unresolved_mark ) ); @@ -245,7 +245,7 @@ where ); let pass = add!(pass, ObjectSuper, es2015::object_super()); let pass = add!(pass, FunctionName, es2015::function_name()); - let pass = add!(pass, ArrowFunctions, es2015::arrow(global_mark)); + let pass = add!(pass, ArrowFunctions, es2015::arrow(unresolved_mark)); let pass = add!(pass, DuplicateKeys, es2015::duplicate_keys()); let pass = add!(pass, StickyRegex, es2015::sticky_regex()); // TODO: InstanceOf, @@ -258,7 +258,7 @@ where es2015::parameters::Config { ignore_function_length: loose || assumptions.ignore_function_length }, - global_mark + unresolved_mark ) ); let pass = add!( @@ -282,8 +282,18 @@ where es2015::destructuring(es2015::destructuring::Config { loose }), true ); - let pass = add!(pass, BlockScoping, es2015::block_scoping(global_mark), true); - let pass = add!(pass, Regenerator, generator(global_mark, comments), true); + let pass = add!( + pass, + BlockScoping, + es2015::block_scoping(unresolved_mark), + true + ); + let pass = add!( + pass, + Regenerator, + generator(unresolved_mark, comments), + true + ); let pass = add!(pass, NewTarget, es2015::new_target(), true); @@ -311,7 +321,7 @@ where let pass = add!( pass, BugfixAsyncArrowsInClass, - bugfixes::async_arrows_in_class(global_mark) + bugfixes::async_arrows_in_class(unresolved_mark) ); let pass = add!( pass, @@ -342,7 +352,7 @@ where targets, includes: included_modules, excludes: excluded_modules, - global_mark + unresolved_mark, }) ) } @@ -356,7 +366,7 @@ struct Polyfills { regenerator: bool, includes: AHashSet, excludes: AHashSet, - global_mark: Mark, + unresolved_mark: Mark, } impl Polyfills { fn collect(&mut self, m: &mut T) -> Vec @@ -496,7 +506,7 @@ impl VisitMut for Polyfills { expr: CallExpr { span, callee: Expr::Ident(Ident { - span: DUMMY_SP.apply_mark(self.global_mark), + span: DUMMY_SP.apply_mark(self.unresolved_mark), sym: "require".into(), optional: false, }) @@ -522,7 +532,7 @@ impl VisitMut for Polyfills { expr: CallExpr { span, callee: Expr::Ident(Ident { - span: DUMMY_SP.apply_mark(self.global_mark), + span: DUMMY_SP.apply_mark(self.unresolved_mark), sym: "require".into(), optional: false, })