fix(es/minifier): Support minifying JSX (#9271)

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/9204
This commit is contained in:
Donny/강동윤 2024-07-18 12:50:59 +09:00 committed by GitHub
parent fa0841c0a5
commit 9a6367b0f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
122 changed files with 613 additions and 319 deletions

View File

@ -9,7 +9,7 @@ use swc_common::{FileName, SourceMap};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_minifier::option::{CompressOptions, MangleOptions, MinifyOptions}; use swc_ecma_minifier::option::{CompressOptions, MangleOptions, MinifyOptions};
use swc_ecma_transforms_base::fixer::fixer; use swc_ecma_transforms_base::fixer::fixer;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use super::{parse_js, print_js, wrap_task, ModuleRecord}; use super::{parse_js, print_js, wrap_task, ModuleRecord};
@ -136,7 +136,7 @@ pub fn get_esbuild_output(file: &Path, mangle: bool) -> Result<String> {
struct Normalizer {} struct Normalizer {}
impl VisitMut for Normalizer { impl VisitMut for Normalizer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_prop(&mut self, p: &mut Prop) { fn visit_mut_prop(&mut self, p: &mut Prop) {
p.visit_mut_children_with(self); p.visit_mut_children_with(self);

View File

@ -22,7 +22,7 @@ use swc_ecma_transforms::{
pass::Optional, pass::Optional,
resolver, Assumptions, resolver, Assumptions,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::config::{CompiledPaths, GlobalPassOption, JsMinifyOptions, ModuleConfig}; use crate::config::{CompiledPaths, GlobalPassOption, JsMinifyOptions, ModuleConfig};
@ -382,7 +382,7 @@ struct MinifierPass<'a> {
} }
impl VisitMut for MinifierPass<'_> { impl VisitMut for MinifierPass<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module(&mut self, m: &mut Module) { fn visit_mut_module(&mut self, m: &mut Module) {
if let Some(options) = &self.options { if let Some(options) = &self.options {

View File

@ -3,7 +3,7 @@ use swc_common::{
BytePos, Span, DUMMY_SP, BytePos, Span, DUMMY_SP,
}; };
use swc_ecma_ast::{Module, Script}; use swc_ecma_ast::{Module, Script};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
/// Preserves comments that would otherwise be dropped. /// Preserves comments that would otherwise be dropped.
/// ///
@ -36,7 +36,7 @@ struct DroppedCommentsPreserver {
type CommentEntries = Vec<(BytePos, Vec<Comment>)>; type CommentEntries = Vec<(BytePos, Vec<Comment>)>;
impl VisitMut for DroppedCommentsPreserver { impl VisitMut for DroppedCommentsPreserver {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module(&mut self, module: &mut Module) { fn visit_mut_module(&mut self, module: &mut Module) {
module.visit_mut_children_with(self); module.visit_mut_children_with(self);

View File

@ -0,0 +1,64 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"target": "es2022",
"loose": false,
"minify": {
"compress": {
"arguments": true,
"arrows": true,
"booleans": true,
"booleans_as_integers": true,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": false,
"directives": true,
"drop_console": true,
"drop_debugger": true,
"evaluate": true,
"expression": true,
"hoist_funs": true,
"hoist_props": true,
"hoist_vars": true,
"if_return": true,
"join_vars": false,
"keep_classnames": true,
"keep_fargs": true,
"keep_fnames": false,
"keep_infinity": true,
"loops": true,
"negate_iife": false,
"properties": true,
"reduce_funcs": true,
"reduce_vars": false,
"side_effects": true,
"switches": true,
"typeofs": true,
"unsafe": false,
"unsafe_arrows": false,
"unsafe_comps": false,
"unsafe_Function": false,
"unsafe_math": false,
"unsafe_symbols": false,
"unsafe_methods": false,
"unsafe_proto": false,
"unsafe_regexp": false,
"unsafe_undefined": false,
"unused": true,
"const_to_let": true,
"pristine_globals": true
},
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}

View File

@ -0,0 +1,8 @@
const Foo = createFoo();
export function App() {
return (
<view>
<Foo />
</view>
);
}

View File

@ -0,0 +1,4 @@
let Foo = createFoo();
export function App() {
return React.createElement("view", null, React.createElement(Foo, null));
}

View File

@ -6,12 +6,12 @@ use swc_common::{comments::SingleThreadedComments, FileName};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_parser::{EsSyntax, Syntax, TsSyntax}; use swc_ecma_parser::{EsSyntax, Syntax, TsSyntax};
use swc_ecma_transforms::pass::noop; use swc_ecma_transforms::pass::noop;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, VisitMut}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, VisitMut};
struct PanicOnVisit; struct PanicOnVisit;
impl VisitMut for PanicOnVisit { impl VisitMut for PanicOnVisit {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_number(&mut self, n: &mut Number) { fn visit_mut_number(&mut self, n: &mut Number) {
panic!("Expected {:?}", n.value) panic!("Expected {:?}", n.value)

View File

@ -4,7 +4,7 @@ use anyhow::Error;
use swc_common::{collections::AHashMap, Span, SyntaxContext, DUMMY_SP}; use swc_common::{collections::AHashMap, Span, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{quote_ident, ExprFactory}; use swc_ecma_utils::{quote_ident, ExprFactory};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::{ use crate::{
bundler::{chunk::merge::Ctx, load::TransformedModule}, bundler::{chunk::merge::Ctx, load::TransformedModule},
@ -189,7 +189,7 @@ where
L: Load, L: Load,
R: Resolve, R: Resolve,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_call_expr(&mut self, node: &mut CallExpr) { fn visit_mut_call_expr(&mut self, node: &mut CallExpr) {
node.visit_mut_children_with(self); node.visit_mut_children_with(self);
@ -352,7 +352,7 @@ struct DefaultHandler {
} }
impl VisitMut for DefaultHandler { impl VisitMut for DefaultHandler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);
@ -375,7 +375,7 @@ struct Remapper {
} }
impl VisitMut for Remapper { impl VisitMut for Remapper {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_ident(&mut self, i: &mut Ident) { fn visit_mut_ident(&mut self, i: &mut Ident) {
if let Some(v) = self.vars.get(&i.to_id()).copied() { if let Some(v) = self.vars.get(&i.to_id()).copied() {

View File

@ -3,7 +3,7 @@ use swc_atoms::JsWord;
use swc_common::{collections::ARandomState, FileName, SyntaxContext}; use swc_common::{collections::ARandomState, FileName, SyntaxContext};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::find_pat_ids; use swc_ecma_utils::find_pat_ids;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use super::{ use super::{
load::{Source, Specifier}, load::{Source, Specifier},
@ -115,7 +115,7 @@ where
L: Load, L: Load,
R: Resolve, R: Resolve,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_item(&mut self, item: &mut ModuleItem) { fn visit_mut_module_item(&mut self, item: &mut ModuleItem) {
match item { match item {

View File

@ -7,7 +7,7 @@ use swc_common::{
}; };
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::find_pat_ids; use swc_ecma_utils::find_pat_ids;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use super::Bundler; use super::Bundler;
use crate::{load::Load, resolve::Resolve, util::ExportMetadata}; use crate::{load::Load, resolve::Resolve, util::ExportMetadata};
@ -365,7 +365,7 @@ where
L: Load, L: Load,
R: Resolve, R: Resolve,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_export_named_specifier(&mut self, s: &mut ExportNamedSpecifier) { fn visit_mut_export_named_specifier(&mut self, s: &mut ExportNamedSpecifier) {
let orig = match &s.orig { let orig = match &s.orig {

View File

@ -1,7 +1,7 @@
use swc_common::{collections::AHashMap, util::take::Take}; use swc_common::{collections::AHashMap, util::take::Take};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::private_ident; use swc_ecma_utils::private_ident;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::id::Id; use crate::id::Id;
@ -31,7 +31,7 @@ impl KeywordRenamer {
} }
impl VisitMut for KeywordRenamer { impl VisitMut for KeywordRenamer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_binding_ident(&mut self, n: &mut BindingIdent) { fn visit_mut_binding_ident(&mut self, n: &mut BindingIdent) {
if let Some(new) = self.renamed(&n.id) { if let Some(new) = self.renamed(&n.id) {

View File

@ -11,7 +11,7 @@ use swc_ecma_ast::{
}; };
use swc_ecma_transforms_base::resolver; use swc_ecma_transforms_base::resolver;
use swc_ecma_visit::{ use swc_ecma_visit::{
noop_visit_type, standard_only_visit_mut, FoldWith, Visit, VisitMut, VisitMutWith, VisitWith, noop_visit_mut_type, noop_visit_type, FoldWith, Visit, VisitMut, VisitMutWith, VisitWith,
}; };
use super::{export::Exports, helpers::Helpers, Bundler}; use super::{export::Exports, helpers::Helpers, Bundler};
@ -486,7 +486,7 @@ impl Visit for Es6ModuleDetector {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
struct ClearMark; struct ClearMark;
impl VisitMut for ClearMark { impl VisitMut for ClearMark {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_ident(&mut self, ident: &mut Ident) { fn visit_mut_ident(&mut self, ident: &mut Ident) {
ident.ctxt = SyntaxContext::empty(); ident.ctxt = SyntaxContext::empty();

View File

@ -1,7 +1,7 @@
use swc_common::{collections::AHashMap, SyntaxContext, DUMMY_SP}; use swc_common::{collections::AHashMap, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{ use swc_ecma_visit::{
noop_visit_type, standard_only_visit_mut, visit_mut_obj_and_computed, Visit, VisitMut, noop_visit_mut_type, noop_visit_type, visit_mut_obj_and_computed, Visit, VisitMut,
VisitMutWith, VisitWith, VisitMutWith, VisitWith,
}; };
@ -84,7 +84,7 @@ impl Visit for Analyzer<'_> {
} }
impl VisitMut for Inliner { impl VisitMut for Inliner {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
visit_mut_obj_and_computed!(); visit_mut_obj_and_computed!();

View File

@ -5,7 +5,7 @@ use std::hash::Hash;
use swc_common::{SyntaxContext, DUMMY_SP}; use swc_common::{SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike; use swc_ecma_utils::ident::IdentLike;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut};
#[cfg(feature = "concurrent")] #[cfg(feature = "concurrent")]
pub(crate) type Readonly<T> = std::sync::Arc<T>; pub(crate) type Readonly<T> = std::sync::Arc<T>;
@ -149,7 +149,7 @@ where
pub(crate) struct HygieneRemover; pub(crate) struct HygieneRemover;
impl VisitMut for HygieneRemover { impl VisitMut for HygieneRemover {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_syntax_context(&mut self, n: &mut SyntaxContext) { fn visit_mut_syntax_context(&mut self, n: &mut SyntaxContext) {
*n = SyntaxContext::empty(); *n = SyntaxContext::empty();

View File

@ -1,5 +1,5 @@
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// Converts destructured parameters with default values to non-shorthand /// Converts destructured parameters with default values to non-shorthand
@ -16,7 +16,7 @@ struct EdgeDefaultParam {
#[swc_trace] #[swc_trace]
impl VisitMut for EdgeDefaultParam { impl VisitMut for EdgeDefaultParam {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) { fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) {
self.in_arrow = true; self.in_arrow = true;

View File

@ -4,7 +4,7 @@ use swc_atoms::JsWord;
use swc_common::{collections::AHashSet, SyntaxContext}; use swc_common::{collections::AHashSet, SyntaxContext};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::hygiene::rename; use swc_ecma_transforms_base::hygiene::rename;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn safari_id_destructuring_collision_in_function_expression() -> impl Fold + VisitMut { pub fn safari_id_destructuring_collision_in_function_expression() -> impl Fold + VisitMut {
@ -31,7 +31,7 @@ impl SafariIdDestructuringCollisionInFunctionExpression {
#[swc_trace] #[swc_trace]
impl VisitMut for SafariIdDestructuringCollisionInFunctionExpression { impl VisitMut for SafariIdDestructuringCollisionInFunctionExpression {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_assign_pat_prop(&mut self, n: &mut AssignPatProp) { fn visit_mut_assign_pat_prop(&mut self, n: &mut AssignPatProp) {
self.visit_mut_pat_id(&Ident::from(&n.key)); self.visit_mut_pat_id(&Ident::from(&n.key));

View File

@ -1,7 +1,7 @@
use swc_common::util::take::Take; use swc_common::util::take::Take;
use swc_ecma_ast::{CallExpr, Expr, Lit, Regex}; use swc_ecma_ast::{CallExpr, Expr, Lit, Regex};
use swc_ecma_utils::{quote_ident, ExprFactory}; use swc_ecma_utils::{quote_ident, ExprFactory};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
pub fn regexp(config: Config) -> impl Fold + VisitMut { pub fn regexp(config: Config) -> impl Fold + VisitMut {
as_folder(RegExp { config }) as_folder(RegExp { config })
@ -32,7 +32,7 @@ struct RegExp {
} }
impl VisitMut for RegExp { impl VisitMut for RegExp {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
expr.visit_mut_children_with(self); expr.visit_mut_children_with(self);

View File

@ -6,9 +6,7 @@ use swc_ecma_utils::{
function::{init_this, FnEnvHoister}, function::{init_this, FnEnvHoister},
prepend_stmt, prepend_stmt,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, InjectVars, VisitMut, VisitMutWith};
as_folder, standard_only_visit_mut, Fold, InjectVars, VisitMut, VisitMutWith,
};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// Compile ES2015 arrow functions to ES5 /// Compile ES2015 arrow functions to ES5
@ -74,7 +72,7 @@ struct Arrow {
#[swc_trace] #[swc_trace]
impl VisitMut for Arrow { impl VisitMut for Arrow {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class(&mut self, c: &mut Class) { fn visit_mut_class(&mut self, c: &mut Class) {
if c.super_class.is_some() { if c.super_class.is_some() {

View File

@ -1,7 +1,7 @@
use swc_common::{util::take::Take, DUMMY_SP}; use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::IdentUsageFinder; use swc_ecma_utils::IdentUsageFinder;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn block_scoped_functions() -> impl Fold + VisitMut { pub fn block_scoped_functions() -> impl Fold + VisitMut {
@ -13,7 +13,7 @@ struct BlockScopedFns;
#[swc_trace] #[swc_trace]
impl VisitMut for BlockScopedFns { impl VisitMut for BlockScopedFns {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_function(&mut self, n: &mut Function) { fn visit_mut_function(&mut self, n: &mut Function) {
let Some(body) = &mut n.body else { return }; let Some(body) = &mut n.body else { return };

View File

@ -16,7 +16,7 @@ use swc_ecma_utils::{
ExprFactory, StmtLike, ExprFactory, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit_mut, visit_mut_obj_and_computed, Fold, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, visit_mut_obj_and_computed, Fold, VisitMut, VisitMutWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -435,7 +435,7 @@ impl BlockScoping {
#[swc_trace] #[swc_trace]
impl VisitMut for BlockScoping { impl VisitMut for BlockScoping {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) { fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) {
n.params.visit_mut_with(self); n.params.visit_mut_with(self);
@ -685,7 +685,7 @@ impl<'a> FlowHelper<'a> {
#[swc_trace] #[swc_trace]
impl VisitMut for FlowHelper<'_> { impl VisitMut for FlowHelper<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
/// noop /// noop
fn visit_mut_arrow_expr(&mut self, _n: &mut ArrowExpr) {} fn visit_mut_arrow_expr(&mut self, _n: &mut ArrowExpr) {}
@ -910,7 +910,7 @@ impl MutationHandler<'_> {
#[swc_trace] #[swc_trace]
impl VisitMut for MutationHandler<'_> { impl VisitMut for MutationHandler<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
visit_mut_obj_and_computed!(); visit_mut_obj_and_computed!();

View File

@ -6,7 +6,7 @@ use swc_common::{
}; };
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::{rename::remap, scope::ScopeKind}; use swc_ecma_transforms_base::{rename::remap, scope::ScopeKind};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub(super) fn block_scoped_vars() -> impl VisitMut { pub(super) fn block_scoped_vars() -> impl VisitMut {
@ -236,7 +236,7 @@ impl ParentScope<'_> {
#[swc_trace] #[swc_trace]
impl VisitMut for BlockScopedVars { impl VisitMut for BlockScopedVars {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) { fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) {
self.with_scope(ScopeKind::Fn, |v| { self.with_scope(ScopeKind::Fn, |v| {

View File

@ -6,7 +6,7 @@ use swc_ecma_transforms_base::helper;
use swc_ecma_transforms_classes::{get_prototype_of, visit_mut_only_key}; use swc_ecma_transforms_classes::{get_prototype_of, visit_mut_only_key};
use swc_ecma_utils::{quote_ident, ExprFactory}; use swc_ecma_utils::{quote_ident, ExprFactory};
use swc_ecma_visit::{ use swc_ecma_visit::{
standard_only_visit, standard_only_visit_mut, Visit, VisitMut, VisitMutWith, VisitWith, noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -66,7 +66,7 @@ macro_rules! mark_as_complex {
#[swc_trace] #[swc_trace]
impl Visit for SuperCallFinder { impl Visit for SuperCallFinder {
standard_only_visit!(); noop_visit_type!(fail);
mark_as_complex!(visit_arrow_expr, ArrowExpr); mark_as_complex!(visit_arrow_expr, ArrowExpr);
@ -174,7 +174,7 @@ pub(super) enum SuperFoldingMode {
#[swc_trace] #[swc_trace]
impl VisitMut for ConstructorFolder<'_> { impl VisitMut for ConstructorFolder<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
visit_mut_only_key!(); visit_mut_only_key!();
@ -474,7 +474,7 @@ pub(super) fn replace_this_in_constructor(mark: Mark, c: &mut Constructor) -> bo
} }
impl VisitMut for Replacer { impl VisitMut for Replacer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
// let computed keys be visited // let computed keys be visited
fn visit_mut_constructor(&mut self, _: &mut Constructor) {} fn visit_mut_constructor(&mut self, _: &mut Constructor) {}

View File

@ -15,8 +15,7 @@ use swc_ecma_utils::{
quote_str, replace_ident, ExprFactory, ModuleItemLike, StmtLike, quote_str, replace_ident, ExprFactory, ModuleItemLike, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
use tracing::debug; use tracing::debug;
@ -224,7 +223,7 @@ impl<C> VisitMut for Classes<C>
where where
C: Comments, C: Comments,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, items: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, items: &mut Vec<ModuleItem>) {
self.visit_mut_stmt_like(items) self.visit_mut_stmt_like(items)
@ -1262,7 +1261,7 @@ fn is_always_initialized(body: &[Stmt]) -> bool {
} }
impl Visit for SuperFinder { impl Visit for SuperFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_callee(&mut self, node: &Callee) { fn visit_callee(&mut self, node: &Callee) {
match *node { match *node {
@ -1317,7 +1316,7 @@ struct ClassFinder {
} }
impl Visit for ClassFinder { impl Visit for ClassFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_class(&mut self, _: &Class) { fn visit_class(&mut self, _: &Class) {
self.found = true self.found = true

View File

@ -4,8 +4,7 @@ use swc_ecma_ast::*;
use swc_ecma_transforms_base::helper; use swc_ecma_transforms_base::helper;
use swc_ecma_utils::{quote_ident, ExprFactory, StmtLike}; use swc_ecma_utils::{quote_ident, ExprFactory, StmtLike};
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -63,7 +62,7 @@ struct ComputedProps {
#[swc_trace] #[swc_trace]
impl VisitMut for ComputedProps { impl VisitMut for ComputedProps {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
expr.visit_mut_children_with(self); expr.visit_mut_children_with(self);
@ -356,7 +355,7 @@ struct ComplexVisitor {
} }
impl Visit for ComplexVisitor { impl Visit for ComplexVisitor {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_prop_name(&mut self, pn: &PropName) { fn visit_prop_name(&mut self, pn: &PropName) {
if let PropName::Computed(..) = *pn { if let PropName::Computed(..) = *pn {
@ -443,7 +442,7 @@ struct ShouldWork {
} }
impl Visit for ShouldWork { impl Visit for ShouldWork {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_prop_name(&mut self, node: &PropName) { fn visit_prop_name(&mut self, node: &PropName) {
if let PropName::Computed(_) = *node { if let PropName::Computed(_) = *node {

View File

@ -11,8 +11,7 @@ use swc_ecma_utils::{
prop_name_to_expr, quote_ident, ExprFactory, StmtLike, prop_name_to_expr, quote_ident, ExprFactory, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -471,7 +470,7 @@ impl AssignFolder {
#[swc_trace] #[swc_trace]
#[fast_path(DestructuringVisitor)] #[fast_path(DestructuringVisitor)]
impl VisitMut for Destructuring { impl VisitMut for Destructuring {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
impl_for_for_stmt!(visit_mut_for_in_stmt, ForInStmt); impl_for_for_stmt!(visit_mut_for_in_stmt, ForInStmt);
@ -598,7 +597,7 @@ impl AssignFolder {
#[swc_trace] #[swc_trace]
#[fast_path(DestructuringVisitor)] #[fast_path(DestructuringVisitor)]
impl VisitMut for AssignFolder { impl VisitMut for AssignFolder {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_export_decl(&mut self, decl: &mut ExportDecl) { fn visit_mut_export_decl(&mut self, decl: &mut ExportDecl) {
let old = self.exporting; let old = self.exporting;
@ -1303,7 +1302,7 @@ struct DestructuringVisitor {
} }
impl Visit for DestructuringVisitor { impl Visit for DestructuringVisitor {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_assign_target_pat(&mut self, _: &AssignTargetPat) { fn visit_assign_target_pat(&mut self, _: &AssignTargetPat) {
self.found = true; self.found = true;

View File

@ -3,7 +3,7 @@ use swc_common::{collections::AHashSet, Spanned};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_base::perf::Parallel;
use swc_ecma_utils::quote_str; use swc_ecma_utils::quote_str;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn duplicate_keys() -> impl Fold + VisitMut { pub fn duplicate_keys() -> impl Fold + VisitMut {
@ -22,7 +22,7 @@ impl Parallel for DuplicateKeys {
#[swc_trace] #[swc_trace]
impl VisitMut for DuplicateKeys { impl VisitMut for DuplicateKeys {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
expr.visit_mut_children_with(self); expr.visit_mut_children_with(self);
@ -42,7 +42,7 @@ struct PropFolder {
#[swc_trace] #[swc_trace]
impl VisitMut for PropFolder { impl VisitMut for PropFolder {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
/// Noop /// Noop
fn visit_mut_expr(&mut self, _: &mut Expr) {} fn visit_mut_expr(&mut self, _: &mut Expr) {}
@ -90,7 +90,7 @@ struct PropNameFolder<'a> {
#[swc_trace] #[swc_trace]
impl<'a> VisitMut for PropNameFolder<'a> { impl<'a> VisitMut for PropNameFolder<'a> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, _: &mut Expr) {} fn visit_mut_expr(&mut self, _: &mut Expr) {}

View File

@ -11,7 +11,7 @@ use swc_ecma_transforms_macros::parallel;
use swc_ecma_utils::{ use swc_ecma_utils::{
alias_if_required, member_expr, prepend_stmt, private_ident, quote_ident, ExprFactory, alias_if_required, member_expr, prepend_stmt, private_ident, quote_ident, ExprFactory,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// `@babel/plugin-transform-for-of` /// `@babel/plugin-transform-for-of`
@ -687,7 +687,7 @@ impl ParExplode for ForOf {
#[swc_trace] #[swc_trace]
#[parallel(explode)] #[parallel(explode)]
impl VisitMut for ForOf { impl VisitMut for ForOf {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_stmt(&mut self, s: &mut Stmt) { fn visit_mut_stmt(&mut self, s: &mut Stmt) {
match s { match s {

View File

@ -2,7 +2,7 @@ use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_base::perf::Parallel;
use swc_ecma_utils::{private_ident, IdentUsageFinder}; use swc_ecma_utils::{private_ident, IdentUsageFinder};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// `@babel/plugin-transform-function-name` /// `@babel/plugin-transform-function-name`
@ -52,7 +52,7 @@ fn prepare(i: Ident) -> Ident {
#[swc_trace] #[swc_trace]
impl VisitMut for FnName { impl VisitMut for FnName {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_assign_expr(&mut self, expr: &mut AssignExpr) { fn visit_mut_assign_expr(&mut self, expr: &mut AssignExpr) {
expr.visit_mut_children_with(self); expr.visit_mut_children_with(self);
@ -135,7 +135,7 @@ macro_rules! noop {
} }
impl VisitMut for Rename { impl VisitMut for Rename {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
impl_for!(visit_mut_fn_expr, FnExpr); impl_for!(visit_mut_fn_expr, FnExpr);

View File

@ -17,8 +17,7 @@ use swc_ecma_utils::{
function::FnEnvHoister, private_ident, prop_name_to_expr_value, quote_ident, ExprFactory, function::FnEnvHoister, private_ident, prop_name_to_expr_value, quote_ident, ExprFactory,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use tracing::debug; use tracing::debug;
@ -48,7 +47,7 @@ macro_rules! dev_span {
} }
impl VisitMut for Wrapper { impl VisitMut for Wrapper {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_function(&mut self, f: &mut Function) { fn visit_mut_function(&mut self, f: &mut Function) {
f.visit_mut_children_with(self); f.visit_mut_children_with(self);
@ -397,7 +396,7 @@ impl Default for Generator {
} }
impl VisitMut for Generator { impl VisitMut for Generator {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_arrow_expr(&mut self, e: &mut ArrowExpr) { fn visit_mut_arrow_expr(&mut self, e: &mut ArrowExpr) {
e.params.visit_mut_with(self); e.params.visit_mut_with(self);
@ -3613,7 +3612,7 @@ struct YieldFinder {
} }
impl Visit for YieldFinder { impl Visit for YieldFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_yield_expr(&mut self, _: &YieldExpr) { fn visit_yield_expr(&mut self, _: &YieldExpr) {
self.found = true; self.found = true;
@ -3642,7 +3641,7 @@ struct InvalidToLit<'a> {
} }
impl VisitMut for InvalidToLit<'_> { impl VisitMut for InvalidToLit<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -2,7 +2,7 @@ use swc_common::{util::take::Take, Span, Spanned};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_transforms_base::{helper, perf::Parallel};
use swc_ecma_utils::ExprFactory; use swc_ecma_utils::ExprFactory;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// `@babel/plugin-transform-instanceof` /// `@babel/plugin-transform-instanceof`
@ -45,7 +45,7 @@ impl Parallel for InstanceOf {
#[swc_trace] #[swc_trace]
impl VisitMut for InstanceOf { impl VisitMut for InstanceOf {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
expr.visit_mut_children_with(self); expr.visit_mut_children_with(self);

View File

@ -5,7 +5,7 @@ use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::{should_work, Check}; use swc_ecma_transforms_base::perf::{should_work, Check};
use swc_ecma_utils::{private_ident, quote_ident, ExprFactory}; use swc_ecma_utils::{private_ident, quote_ident, ExprFactory};
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -37,7 +37,7 @@ impl NewTarget {
#[swc_trace] #[swc_trace]
impl VisitMut for NewTarget { impl VisitMut for NewTarget {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class_method(&mut self, c: &mut ClassMethod) { fn visit_mut_class_method(&mut self, c: &mut ClassMethod) {
c.key.visit_mut_with(self); c.key.visit_mut_with(self);
@ -149,7 +149,7 @@ struct ShouldWork {
} }
impl Visit for ShouldWork { impl Visit for ShouldWork {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_meta_prop_expr(&mut self, n: &MetaPropExpr) { fn visit_meta_prop_expr(&mut self, n: &MetaPropExpr) {
if let MetaPropExpr { if let MetaPropExpr {

View File

@ -6,7 +6,7 @@ use swc_ecma_transforms_base::helper;
use swc_ecma_utils::{ use swc_ecma_utils::{
alias_ident_for, is_rest_arguments, prepend_stmt, private_ident, quote_ident, ExprFactory, alias_ident_for, is_rest_arguments, prepend_stmt, private_ident, quote_ident, ExprFactory,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
struct ObjectSuper { struct ObjectSuper {
@ -21,7 +21,7 @@ pub fn object_super() -> impl Fold + VisitMut {
#[swc_trace] #[swc_trace]
impl VisitMut for ObjectSuper { impl VisitMut for ObjectSuper {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
n.visit_mut_children_with(self); n.visit_mut_children_with(self);
@ -134,7 +134,7 @@ struct SuperReplacer {
#[swc_trace] #[swc_trace]
impl VisitMut for SuperReplacer { impl VisitMut for SuperReplacer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_object_lit(&mut self, obj: &mut ObjectLit) { fn visit_mut_object_lit(&mut self, obj: &mut ObjectLit) {
for prop_or_spread in obj.props.iter_mut() { for prop_or_spread in obj.props.iter_mut() {

View File

@ -10,7 +10,7 @@ use swc_ecma_utils::{
function::{init_this, FnEnvHoister}, function::{init_this, FnEnvHoister},
member_expr, prepend_stmt, prepend_stmts, private_ident, quote_ident, ExprFactory, member_expr, prepend_stmt, prepend_stmts, private_ident, quote_ident, ExprFactory,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
use tracing::trace; use tracing::trace;
@ -466,7 +466,7 @@ impl Params {
#[swc_trace] #[swc_trace]
impl VisitMut for Params { impl VisitMut for Params {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
// generally speaking, there won't be class field in here, but Safari 14.1 // generally speaking, there won't be class field in here, but Safari 14.1
// still has bugs in parameters // still has bugs in parameters

View File

@ -1,7 +1,7 @@
use swc_common::util::take::Take; use swc_common::util::take::Take;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_base::perf::Parallel;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// Compile ES2015 shorthand properties to ES5 /// Compile ES2015 shorthand properties to ES5
@ -55,7 +55,7 @@ impl Parallel for Shorthand {
#[swc_trace] #[swc_trace]
impl VisitMut for Shorthand { impl VisitMut for Shorthand {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_prop(&mut self, prop: &mut Prop) { fn visit_mut_prop(&mut self, prop: &mut Prop) {
prop.visit_mut_children_with(self); prop.visit_mut_children_with(self);

View File

@ -9,8 +9,7 @@ use swc_ecma_utils::{
alias_ident_for, member_expr, prepend_stmt, quote_ident, ExprFactory, StmtLike, alias_ident_for, member_expr, prepend_stmt, quote_ident, ExprFactory, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -37,7 +36,7 @@ struct Spread {
#[swc_trace] #[swc_trace]
#[fast_path(SpreadFinder)] #[fast_path(SpreadFinder)]
impl VisitMut for Spread { impl VisitMut for Spread {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
self.visit_mut_stmt_like(n); self.visit_mut_stmt_like(n);
@ -506,7 +505,7 @@ struct SpreadFinder {
} }
impl Visit for SpreadFinder { impl Visit for SpreadFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_expr_or_spread(&mut self, n: &ExprOrSpread) { fn visit_expr_or_spread(&mut self, n: &ExprOrSpread) {
n.visit_children_with(self); n.visit_children_with(self);

View File

@ -1,7 +1,7 @@
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_base::perf::Parallel;
use swc_ecma_utils::{quote_ident, ExprFactory}; use swc_ecma_utils::{quote_ident, ExprFactory};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// Compile ES2015 sticky regex to an ES5 RegExp constructor /// Compile ES2015 sticky regex to an ES5 RegExp constructor
@ -34,7 +34,7 @@ impl Parallel for StickyRegex {
#[swc_trace] #[swc_trace]
impl VisitMut for StickyRegex { impl VisitMut for StickyRegex {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -6,7 +6,7 @@ use swc_common::{util::take::Take, BytePos, Spanned, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_transforms_base::{helper, perf::Parallel};
use swc_ecma_utils::{is_literal, prepend_stmts, private_ident, quote_ident, ExprFactory}; use swc_ecma_utils::{is_literal, prepend_stmts, private_ident, quote_ident, ExprFactory};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn template_literal(c: Config) -> impl Fold + VisitMut { pub fn template_literal(c: Config) -> impl Fold + VisitMut {
@ -43,7 +43,7 @@ impl Parallel for TemplateLiteral {
#[swc_trace] #[swc_trace]
impl VisitMut for TemplateLiteral { impl VisitMut for TemplateLiteral {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -2,7 +2,7 @@ use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_transforms_base::{helper, perf::Parallel};
use swc_ecma_utils::{quote_str, ExprFactory}; use swc_ecma_utils::{quote_str, ExprFactory};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn typeof_symbol() -> impl VisitMut + Fold { pub fn typeof_symbol() -> impl VisitMut + Fold {
@ -23,7 +23,7 @@ impl Parallel for TypeOfSymbol {
#[swc_trace] #[swc_trace]
impl VisitMut for TypeOfSymbol { impl VisitMut for TypeOfSymbol {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_bin_expr(&mut self, expr: &mut BinExpr) { fn visit_mut_bin_expr(&mut self, expr: &mut BinExpr) {
match expr.op { match expr.op {

View File

@ -3,7 +3,7 @@ use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::{ParExplode, Parallel}; use swc_ecma_transforms_base::perf::{ParExplode, Parallel};
use swc_ecma_transforms_macros::parallel; use swc_ecma_transforms_macros::parallel;
use swc_ecma_utils::{member_expr, private_ident, ExprFactory}; use swc_ecma_utils::{member_expr, private_ident, ExprFactory};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
/// `@babel/plugin-transform-exponentiation-operator` /// `@babel/plugin-transform-exponentiation-operator`
@ -80,7 +80,7 @@ impl ParExplode for Exponentiation {
#[swc_trace] #[swc_trace]
#[parallel(explode)] #[parallel(explode)]
impl VisitMut for Exponentiation { impl VisitMut for Exponentiation {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -13,8 +13,7 @@ use swc_ecma_utils::{
private_ident, quote_ident, ExprFactory, Remapper, StmtLike, private_ident, quote_ident, ExprFactory, Remapper, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -78,7 +77,7 @@ struct Actual<C: Comments> {
#[swc_trace] #[swc_trace]
#[fast_path(ShouldWork)] #[fast_path(ShouldWork)]
impl<C: Comments + Clone> VisitMut for AsyncToGenerator<C> { impl<C: Comments + Clone> VisitMut for AsyncToGenerator<C> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
self.visit_mut_stmt_like(n); self.visit_mut_stmt_like(n);
@ -121,7 +120,7 @@ impl<C: Comments + Clone> AsyncToGenerator<C> {
#[swc_trace] #[swc_trace]
#[fast_path(ShouldWork)] #[fast_path(ShouldWork)]
impl<C: Comments> VisitMut for Actual<C> { impl<C: Comments> VisitMut for Actual<C> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class_method(&mut self, m: &mut ClassMethod) { fn visit_mut_class_method(&mut self, m: &mut ClassMethod) {
if m.function.body.is_none() { if m.function.body.is_none() {
@ -450,7 +449,7 @@ macro_rules! noop {
#[swc_trace] #[swc_trace]
impl VisitMut for AsyncFnBodyHandler { impl VisitMut for AsyncFnBodyHandler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
noop!(visit_mut_fn_expr, FnExpr); noop!(visit_mut_fn_expr, FnExpr);
@ -537,7 +536,7 @@ struct ShouldWork {
#[swc_trace] #[swc_trace]
impl Visit for ShouldWork { impl Visit for ShouldWork {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_function(&mut self, f: &Function) { fn visit_function(&mut self, f: &Function) {
if f.is_async { if f.is_async {

View File

@ -13,7 +13,7 @@ use swc_ecma_utils::{
var::VarCollector, ExprFactory, StmtLike, var::VarCollector, ExprFactory, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
standard_only_visit, standard_only_visit_mut, Visit, VisitMut, VisitMutWith, VisitWith, noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -166,7 +166,7 @@ struct RestVisitor {
#[swc_trace] #[swc_trace]
impl Visit for RestVisitor { impl Visit for RestVisitor {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_object_pat_prop(&mut self, prop: &ObjectPatProp) { fn visit_object_pat_prop(&mut self, prop: &ObjectPatProp) {
match *prop { match *prop {
@ -194,7 +194,7 @@ where
#[swc_trace] #[swc_trace]
#[fast_path(RestVisitor)] #[fast_path(RestVisitor)]
impl VisitMut for ObjectRest { impl VisitMut for ObjectRest {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
impl_for_for_stmt!(visit_mut_for_in_stmt, ForInStmt); impl_for_for_stmt!(visit_mut_for_in_stmt, ForInStmt);
@ -1013,7 +1013,7 @@ struct PatSimplifier;
#[swc_trace] #[swc_trace]
impl VisitMut for PatSimplifier { impl VisitMut for PatSimplifier {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_pat(&mut self, pat: &mut Pat) { fn visit_mut_pat(&mut self, pat: &mut Pat) {
pat.visit_mut_children_with(self); pat.visit_mut_children_with(self);

View File

@ -2,7 +2,7 @@ use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::{helper, perf::Parallel}; use swc_ecma_transforms_base::{helper, perf::Parallel};
use swc_ecma_utils::ExprFactory; use swc_ecma_utils::ExprFactory;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
use super::object_rest_spread::Config; use super::object_rest_spread::Config;
@ -24,7 +24,7 @@ impl Parallel for ObjectSpread {
#[swc_trace] #[swc_trace]
impl VisitMut for ObjectSpread { impl VisitMut for ObjectSpread {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
expr.visit_mut_children_with(self); expr.visit_mut_children_with(self);

View File

@ -1,6 +1,6 @@
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::private_ident; use swc_ecma_utils::private_ident;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
struct OptionalCatchBinding; struct OptionalCatchBinding;
@ -11,7 +11,7 @@ pub fn optional_catch_binding() -> impl Fold + VisitMut {
#[swc_trace] #[swc_trace]
impl VisitMut for OptionalCatchBinding { impl VisitMut for OptionalCatchBinding {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_catch_clause(&mut self, cc: &mut CatchClause) { fn visit_mut_catch_clause(&mut self, cc: &mut CatchClause) {
cc.visit_mut_children_with(self); cc.visit_mut_children_with(self);

View File

@ -1,7 +1,7 @@
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::private_ident; use swc_ecma_utils::private_ident;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn export_namespace_from() -> impl Fold + VisitMut { pub fn export_namespace_from() -> impl Fold + VisitMut {
@ -12,7 +12,7 @@ struct ExportNamespaceFrom;
#[swc_trace] #[swc_trace]
impl VisitMut for ExportNamespaceFrom { impl VisitMut for ExportNamespaceFrom {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, items: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, items: &mut Vec<ModuleItem>) {
let count = items let count = items

View File

@ -4,7 +4,7 @@ use serde::Deserialize;
use swc_common::{util::take::Take, Span, DUMMY_SP}; use swc_common::{util::take::Take, Span, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{alias_ident_for_simple_assign_tatget, alias_if_required, StmtLike}; use swc_ecma_utils::{alias_ident_for_simple_assign_tatget, alias_if_required, StmtLike};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn nullish_coalescing(c: Config) -> impl Fold + VisitMut + 'static { pub fn nullish_coalescing(c: Config) -> impl Fold + VisitMut + 'static {
@ -60,7 +60,7 @@ impl NullishCoalescing {
#[swc_trace] #[swc_trace]
impl VisitMut for NullishCoalescing { impl VisitMut for NullishCoalescing {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
/// Prevents #1123 /// Prevents #1123
fn visit_mut_block_stmt(&mut self, s: &mut BlockStmt) { fn visit_mut_block_stmt(&mut self, s: &mut BlockStmt) {

View File

@ -4,7 +4,7 @@ use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_base::perf::Parallel;
use swc_ecma_utils::{alias_ident_for, prepend_stmt}; use swc_ecma_utils::{alias_ident_for, prepend_stmt};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub fn logical_assignments() -> impl Fold + VisitMut { pub fn logical_assignments() -> impl Fold + VisitMut {
@ -58,7 +58,7 @@ impl Parallel for Operators {
#[swc_trace] #[swc_trace]
impl VisitMut for Operators { impl VisitMut for Operators {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -2,7 +2,7 @@ use swc_common::DUMMY_SP;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::helper; use swc_ecma_transforms_base::helper;
use swc_ecma_utils::ExprFactory; use swc_ecma_utils::ExprFactory;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub(super) struct ClassNameTdzFolder<'a> { pub(super) struct ClassNameTdzFolder<'a> {
@ -11,7 +11,7 @@ pub(super) struct ClassNameTdzFolder<'a> {
#[swc_trace] #[swc_trace]
impl<'a> VisitMut for ClassNameTdzFolder<'a> { impl<'a> VisitMut for ClassNameTdzFolder<'a> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
match expr { match expr {

View File

@ -12,8 +12,7 @@ use swc_ecma_utils::{
ModuleItemLike, StmtLike, ModuleItemLike, StmtLike,
}; };
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
@ -160,7 +159,7 @@ impl Take for ClassExtra {
#[swc_trace] #[swc_trace]
#[fast_path(ShouldWork)] #[fast_path(ShouldWork)]
impl<C: Comments> VisitMut for ClassProperties<C> { impl<C: Comments> VisitMut for ClassProperties<C> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
self.visit_mut_stmt_like(n); self.visit_mut_stmt_like(n);
@ -1081,7 +1080,7 @@ struct ShouldWork {
#[swc_trace] #[swc_trace]
impl Visit for ShouldWork { impl Visit for ShouldWork {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_class_method(&mut self, _: &ClassMethod) { fn visit_class_method(&mut self, _: &ClassMethod) {
self.found = true; self.found = true;
@ -1116,7 +1115,7 @@ struct SuperVisitor {
} }
impl Visit for SuperVisitor { impl Visit for SuperVisitor {
standard_only_visit!(); noop_visit_type!(fail);
/// Don't recurse into constructor /// Don't recurse into constructor
fn visit_constructor(&mut self, _: &Constructor) {} fn visit_constructor(&mut self, _: &Constructor) {}

View File

@ -8,7 +8,7 @@ use swc_common::{
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::helper; use swc_ecma_transforms_base::helper;
use swc_ecma_utils::{alias_ident_for, alias_if_required, prepend_stmt, quote_ident, ExprFactory}; use swc_ecma_utils::{alias_ident_for, alias_if_required, prepend_stmt, quote_ident, ExprFactory};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
use super::Config; use super::Config;
@ -86,7 +86,7 @@ pub(super) struct BrandCheckHandler<'a> {
#[swc_trace] #[swc_trace]
impl VisitMut for BrandCheckHandler<'_> { impl VisitMut for BrandCheckHandler<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);
@ -205,7 +205,7 @@ macro_rules! take_vars {
// super.#sdsa is invalid // super.#sdsa is invalid
#[swc_trace] #[swc_trace]
impl<'a> VisitMut for PrivateAccessVisitor<'a> { impl<'a> VisitMut for PrivateAccessVisitor<'a> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
take_vars!(visit_mut_function, Function); take_vars!(visit_mut_function, Function);

View File

@ -1,5 +1,5 @@
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub(super) struct ThisInStaticFolder { pub(super) struct ThisInStaticFolder {
@ -8,7 +8,7 @@ pub(super) struct ThisInStaticFolder {
#[swc_trace] #[swc_trace]
impl VisitMut for ThisInStaticFolder { impl VisitMut for ThisInStaticFolder {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
// once again, for computed props // once again, for computed props
fn visit_mut_constructor(&mut self, _: &mut Constructor) {} fn visit_mut_constructor(&mut self, _: &mut Constructor) {}
@ -28,7 +28,7 @@ pub(super) struct NewTargetInProp;
#[swc_trace] #[swc_trace]
impl VisitMut for NewTargetInProp { impl VisitMut for NewTargetInProp {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
// once again, for computed props // once again, for computed props
fn visit_mut_constructor(&mut self, _: &mut Constructor) {} fn visit_mut_constructor(&mut self, _: &mut Constructor) {}

View File

@ -1,6 +1,6 @@
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
pub(super) struct UsedNameCollector<'a> { pub(super) struct UsedNameCollector<'a> {
@ -16,7 +16,7 @@ macro_rules! noop {
#[swc_trace] #[swc_trace]
impl<'a> Visit for UsedNameCollector<'a> { impl<'a> Visit for UsedNameCollector<'a> {
standard_only_visit!(); noop_visit_type!(fail);
noop!(visit_arrow_expr, ArrowExpr); noop!(visit_arrow_expr, ArrowExpr);

View File

@ -3,7 +3,7 @@ use std::mem;
use swc_common::{util::take::Take, Mark, SyntaxContext, DUMMY_SP}; use swc_common::{util::take::Take, Mark, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{alias_ident_for, prepend_stmt, quote_ident, ExprFactory, StmtLike}; use swc_ecma_utils::{alias_ident_for, prepend_stmt, quote_ident, ExprFactory, StmtLike};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
/// Not a public API and may break any time. Don't use it directly. /// Not a public API and may break any time. Don't use it directly.
pub fn optional_chaining_impl(c: Config, unresolved_mark: Mark) -> OptionalChaining { pub fn optional_chaining_impl(c: Config, unresolved_mark: Mark) -> OptionalChaining {
@ -35,7 +35,7 @@ pub struct Config {
} }
impl VisitMut for OptionalChaining { impl VisitMut for OptionalChaining {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_block_stmt_or_expr(&mut self, expr: &mut BlockStmtOrExpr) { fn visit_mut_block_stmt_or_expr(&mut self, expr: &mut BlockStmtOrExpr) {
if let BlockStmtOrExpr::Expr(e) = expr { if let BlockStmtOrExpr::Expr(e) = expr {

View File

@ -12,8 +12,7 @@ use swc_ecma_ast::*;
use swc_ecma_transforms_base::pass::JsPass; use swc_ecma_transforms_base::pass::JsPass;
use swc_ecma_utils::{default_constructor, prepend_stmt, private_ident, quote_ident, ExprFactory}; use swc_ecma_utils::{default_constructor, prepend_stmt, private_ident, quote_ident, ExprFactory};
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Visit, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith,
VisitWith,
}; };
/// https://github.com/tc39/proposal-private-fields-in-in /// https://github.com/tc39/proposal-private-fields-in-in
@ -131,7 +130,7 @@ impl PrivateInObject {
} }
impl VisitMut for PrivateInObject { impl VisitMut for PrivateInObject {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class(&mut self, n: &mut Class) { fn visit_mut_class(&mut self, n: &mut Class) {
{ {
@ -496,7 +495,7 @@ struct ClassAnalyzer<'a> {
} }
impl Visit for ClassAnalyzer<'_> { impl Visit for ClassAnalyzer<'_> {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_bin_expr(&mut self, n: &BinExpr) { fn visit_bin_expr(&mut self, n: &BinExpr) {
n.visit_children_with(self); n.visit_children_with(self);

View File

@ -2,7 +2,7 @@ use swc_atoms::JsWord;
use swc_common::{collections::AHashSet, util::take::Take, Mark, SyntaxContext, DUMMY_SP}; use swc_common::{collections::AHashSet, util::take::Take, Mark, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::ExprFactory; use swc_ecma_utils::ExprFactory;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use swc_trace_macro::swc_trace; use swc_trace_macro::swc_trace;
struct ClassStaticBlock { struct ClassStaticBlock {
@ -71,7 +71,7 @@ impl ClassStaticBlock {
#[swc_trace] #[swc_trace]
impl VisitMut for ClassStaticBlock { impl VisitMut for ClassStaticBlock {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class(&mut self, class: &mut Class) { fn visit_mut_class(&mut self, class: &mut Class) {
class.visit_mut_children_with(self); class.visit_mut_children_with(self);

View File

@ -1,6 +1,6 @@
use swc_common::{util::take::Take, DUMMY_SP}; use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
/// babel: `@babel/plugin-transform-reserved-words` /// babel: `@babel/plugin-transform-reserved-words`
/// ///
@ -27,7 +27,7 @@ struct ReservedWord {
} }
impl VisitMut for ReservedWord { impl VisitMut for ReservedWord {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
let mut extra_exports = vec![]; let mut extra_exports = vec![];

View File

@ -4,7 +4,7 @@ use swc_common::{collections::AHashSet, pass::Repeated, util::take::Take, DUMMY_
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_usage_analyzer::analyzer::UsageAnalyzer; use swc_ecma_usage_analyzer::analyzer::UsageAnalyzer;
use swc_ecma_utils::{find_pat_ids, StmtLike}; use swc_ecma_utils::{find_pat_ids, StmtLike};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith, VisitWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
use super::util::drop_invalid_stmts; use super::util::drop_invalid_stmts;
use crate::{ use crate::{
@ -279,7 +279,7 @@ impl Hoister<'_> {
} }
impl VisitMut for Hoister<'_> { impl VisitMut for Hoister<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, stmts: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, stmts: &mut Vec<ModuleItem>) {
self.handle_stmt_likes(stmts); self.handle_stmt_likes(stmts);

View File

@ -15,7 +15,7 @@ use swc_ecma_transforms_optimization::simplify::{
dead_branch_remover, expr_simplifier, ExprSimplifierConfig, dead_branch_remover, expr_simplifier, ExprSimplifierConfig,
}; };
use swc_ecma_usage_analyzer::{analyzer::UsageAnalyzer, marks::Marks}; use swc_ecma_usage_analyzer::{analyzer::UsageAnalyzer, marks::Marks};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, VisitMut, VisitMutWith, VisitWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
use swc_timer::timer; use swc_timer::timer;
use tracing::{debug, error}; use tracing::{debug, error};
@ -325,7 +325,7 @@ impl Compressor<'_> {
} }
impl VisitMut for Compressor<'_> { impl VisitMut for Compressor<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_script(&mut self, n: &mut Script) { fn visit_mut_script(&mut self, n: &mut Script) {
self.optimize_unit_repeatedly(n); self.optimize_unit_repeatedly(n);

View File

@ -3,7 +3,7 @@ use std::iter::repeat_with;
use swc_common::{util::take::Take, DUMMY_SP}; use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{find_pat_ids, is_valid_prop_ident, private_ident}; use swc_ecma_utils::{find_pat_ids, is_valid_prop_ident, private_ident};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use super::Optimizer; use super::Optimizer;
use crate::compress::optimize::is_left_access_to_arguments; use crate::compress::optimize::is_left_access_to_arguments;
@ -146,7 +146,7 @@ impl ArgReplacer<'_> {
} }
impl VisitMut for ArgReplacer<'_> { impl VisitMut for ArgReplacer<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
/// Noop. /// Noop.
fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {} fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {}

View File

@ -2,7 +2,7 @@ use swc_common::{util::take::Take, Spanned, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_optimization::debug_assert_valid; use swc_ecma_transforms_optimization::debug_assert_valid;
use swc_ecma_utils::{StmtExt, StmtLike}; use swc_ecma_utils::{StmtExt, StmtLike};
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use super::Optimizer; use super::Optimizer;
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
@ -529,7 +529,7 @@ pub(super) struct ReturnFinder {
} }
impl Visit for ReturnFinder { impl Visit for ReturnFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_return_stmt(&mut self, n: &ReturnStmt) { fn visit_return_stmt(&mut self, n: &ReturnStmt) {
n.visit_children_with(self); n.visit_children_with(self);

View File

@ -14,7 +14,7 @@ use swc_ecma_usage_analyzer::{analyzer::UsageAnalyzer, marks::Marks};
use swc_ecma_utils::{ use swc_ecma_utils::{
prepend_stmts, ExprCtx, ExprExt, ExprFactory, IsEmpty, ModuleItemLike, StmtLike, Type, Value, prepend_stmts, ExprCtx, ExprExt, ExprFactory, IsEmpty, ModuleItemLike, StmtLike, Type, Value,
}; };
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith, VisitWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
use tracing::{debug, span, Level}; use tracing::{debug, span, Level};
use Value::Known; use Value::Known;
@ -1497,7 +1497,7 @@ impl Optimizer<'_> {
} }
impl VisitMut for Optimizer<'_> { impl VisitMut for Optimizer<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))] #[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) { fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) {

View File

@ -9,7 +9,7 @@ use swc_ecma_usage_analyzer::{
use swc_ecma_utils::{ use swc_ecma_utils::{
contains_arguments, contains_this_expr, prepend_stmts, ExprExt, IdentUsageFinder, StmtLike, contains_arguments, contains_this_expr, prepend_stmts, ExprExt, IdentUsageFinder, StmtLike,
}; };
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
use tracing::{span, Level}; use tracing::{span, Level};
@ -2597,7 +2597,7 @@ struct UsageCounter<'a> {
} }
impl Visit for UsageCounter<'_> { impl Visit for UsageCounter<'_> {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_ident(&mut self, i: &Ident) { fn visit_ident(&mut self, i: &Ident) {
if self.target.sym == i.sym && self.target.ctxt == i.ctxt { if self.target.sym == i.sym && self.target.ctxt == i.ctxt {

View File

@ -1,7 +1,7 @@
use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, SyntaxContext, DUMMY_SP}; use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{prepend_stmt, ExprExt, ExprFactory, StmtExt}; use swc_ecma_utils::{prepend_stmt, ExprExt, ExprFactory, StmtExt};
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use super::Optimizer; use super::Optimizer;
use crate::{compress::util::is_primitive, util::idents_used_by}; use crate::{compress::util::is_primitive, util::idents_used_by};
@ -560,7 +560,7 @@ struct BreakFinder {
} }
impl Visit for BreakFinder { impl Visit for BreakFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_break_stmt(&mut self, s: &BreakStmt) { fn visit_break_stmt(&mut self, s: &BreakStmt) {
if !self.top_level && s.label.is_none() { if !self.top_level && s.label.is_none() {

View File

@ -4,7 +4,7 @@ use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_usage_analyzer::util::is_global_var_with_pure_property_access; use swc_ecma_usage_analyzer::util::is_global_var_with_pure_property_access;
use swc_ecma_utils::{contains_ident_ref, contains_this_expr, ExprExt}; use swc_ecma_utils::{contains_ident_ref, contains_this_expr, ExprExt};
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use super::Optimizer; use super::Optimizer;
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
@ -942,7 +942,7 @@ struct ThisPropertyVisitor {
} }
impl Visit for ThisPropertyVisitor { impl Visit for ThisPropertyVisitor {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_assign_expr(&mut self, e: &AssignExpr) { fn visit_assign_expr(&mut self, e: &AssignExpr) {
if self.should_abort { if self.should_abort {

View File

@ -9,7 +9,7 @@ use swc_common::{collections::AHashSet, util::take::Take, Mark, SyntaxContext, D
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::{Parallel, ParallelExt}; use swc_ecma_transforms_base::perf::{Parallel, ParallelExt};
use swc_ecma_utils::{collect_decls, ExprCtx, ExprExt, Remapper}; use swc_ecma_utils::{collect_decls, ExprCtx, ExprExt, Remapper};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use tracing::debug; use tracing::debug;
use super::{Ctx, Optimizer}; use super::{Ctx, Optimizer};
@ -307,7 +307,7 @@ enum FinalizerMode {
} }
impl VisitMut for Finalizer<'_> { impl VisitMut for Finalizer<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_callee(&mut self, e: &mut Callee) { fn visit_mut_callee(&mut self, e: &mut Callee) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);
@ -483,7 +483,7 @@ impl<'a> NormalMultiReplacer<'a> {
} }
impl VisitMut for NormalMultiReplacer<'_> { impl VisitMut for NormalMultiReplacer<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
if self.vars.is_empty() { if self.vars.is_empty() {
@ -568,7 +568,7 @@ impl ExprReplacer {
} }
impl VisitMut for ExprReplacer { impl VisitMut for ExprReplacer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -3,7 +3,7 @@ use rayon::prelude::*;
use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP}; use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{extract_var_ids, ExprCtx, ExprExt, StmtExt, StmtLike, Value}; use swc_ecma_utils::{extract_var_ids, ExprCtx, ExprExt, StmtExt, StmtLike, Value};
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use super::Pure; use super::Pure;
use crate::{compress::util::is_fine_for_if_cons, maybe_par, util::ModuleItemExt}; use crate::{compress::util::is_fine_for_if_cons, maybe_par, util::ModuleItemExt};
@ -610,7 +610,7 @@ struct LabelFinder<'a> {
found: bool, found: bool,
} }
impl Visit for LabelFinder<'_> { impl Visit for LabelFinder<'_> {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_break_stmt(&mut self, s: &BreakStmt) { fn visit_break_stmt(&mut self, s: &BreakStmt) {
match &s.label { match &s.label {

View File

@ -7,7 +7,7 @@ use swc_ecma_ast::*;
use swc_ecma_transforms_optimization::debug_assert_valid; use swc_ecma_transforms_optimization::debug_assert_valid;
use swc_ecma_usage_analyzer::marks::Marks; use swc_ecma_usage_analyzer::marks::Marks;
use swc_ecma_utils::ExprCtx; use swc_ecma_utils::ExprCtx;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith, VisitWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
use tracing::{debug, span, Level}; use tracing::{debug, span, Level};
@ -254,7 +254,7 @@ impl Pure<'_> {
} }
impl VisitMut for Pure<'_> { impl VisitMut for Pure<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_assign_expr(&mut self, e: &mut AssignExpr) { fn visit_mut_assign_expr(&mut self, e: &mut AssignExpr) {
{ {

View File

@ -3,7 +3,7 @@ use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{prepend_stmt, StmtLike}; use swc_ecma_utils::{prepend_stmt, StmtLike};
use swc_ecma_visit::{ use swc_ecma_visit::{
standard_only_visit, standard_only_visit_mut, Visit, VisitMut, VisitMutWith, VisitWith, noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith,
}; };
use super::Pure; use super::Pure;
@ -300,7 +300,7 @@ pub(super) struct VarWithOutInitCounter {
} }
impl Visit for VarWithOutInitCounter { impl Visit for VarWithOutInitCounter {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_arrow_expr(&mut self, _: &ArrowExpr) {} fn visit_arrow_expr(&mut self, _: &ArrowExpr) {}
@ -368,7 +368,7 @@ pub(super) struct VarMover {
} }
impl VisitMut for VarMover { impl VisitMut for VarMover {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
/// Noop /// Noop
fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {} fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {}
@ -486,7 +486,7 @@ pub(super) struct VarPrepender {
} }
impl VisitMut for VarPrepender { impl VisitMut for VarPrepender {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
/// Noop /// Noop
fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {} fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {}

View File

@ -8,7 +8,7 @@ use swc_ecma_utils::{number::JsNumber, ExprCtx, ExprExt, IdentUsageFinder, Value
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
use swc_ecma_visit::{as_folder, FoldWith}; use swc_ecma_visit::{as_folder, FoldWith};
use swc_ecma_visit::{ use swc_ecma_visit::{
standard_only_visit, standard_only_visit_mut, Visit, VisitMut, VisitMutWith, VisitWith, noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith,
}; };
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
@ -568,7 +568,7 @@ impl<F> VisitMut for ExprReplacer<F>
where where
F: FnMut(&mut Expr), F: FnMut(&mut Expr),
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);
@ -687,7 +687,7 @@ impl UnreachableHandler {
} }
impl VisitMut for UnreachableHandler { impl VisitMut for UnreachableHandler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {} fn visit_mut_arrow_expr(&mut self, _: &mut ArrowExpr) {}
@ -737,7 +737,7 @@ pub struct SuperFinder {
} }
impl Visit for SuperFinder { impl Visit for SuperFinder {
standard_only_visit!(); noop_visit_type!(fail);
/// Don't recurse into constructor /// Don't recurse into constructor
fn visit_constructor(&mut self, _: &Constructor) {} fn visit_constructor(&mut self, _: &Constructor) {}

View File

@ -3,7 +3,7 @@ use swc_ecma_ast::*;
use swc_ecma_parser::parse_file_as_expr; use swc_ecma_parser::parse_file_as_expr;
use swc_ecma_transforms_base::fixer::fixer; use swc_ecma_transforms_base::fixer::fixer;
use swc_ecma_utils::ExprCtx; use swc_ecma_utils::ExprCtx;
use swc_ecma_visit::{standard_only_visit_mut, FoldWith, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, FoldWith, VisitMut, VisitMutWith};
use tracing::{info, warn}; use tracing::{info, warn};
use super::negate_cost; use super::negate_cost;
@ -11,7 +11,7 @@ use crate::{compress::util::negate, debug::dump};
struct UnwrapParen; struct UnwrapParen;
impl VisitMut for UnwrapParen { impl VisitMut for UnwrapParen {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -9,13 +9,13 @@ use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
use swc_ecma_transforms_base::{fixer::fixer, hygiene::hygiene}; use swc_ecma_transforms_base::{fixer::fixer, hygiene::hygiene};
pub use swc_ecma_transforms_optimization::{debug_assert_valid, AssertValid}; pub use swc_ecma_transforms_optimization::{debug_assert_valid, AssertValid};
use swc_ecma_utils::{drop_span, DropSpan}; use swc_ecma_utils::{drop_span, DropSpan};
use swc_ecma_visit::{standard_only_visit_mut, FoldWith, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, FoldWith, VisitMut, VisitMutWith};
use tracing::debug; use tracing::debug;
pub(crate) struct Debugger {} pub(crate) struct Debugger {}
impl VisitMut for Debugger { impl VisitMut for Debugger {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_ident(&mut self, n: &mut Ident) { fn visit_mut_ident(&mut self, n: &mut Ident) {
if !cfg!(feature = "debug") { if !cfg!(feature = "debug") {

View File

@ -7,7 +7,7 @@ use swc_ecma_ast::*;
use swc_ecma_usage_analyzer::marks::Marks; use swc_ecma_usage_analyzer::marks::Marks;
use swc_ecma_utils::NodeIgnoringSpan; use swc_ecma_utils::NodeIgnoringSpan;
use swc_ecma_visit::{ use swc_ecma_visit::{
standard_only_visit, standard_only_visit_mut, Visit, VisitMut, VisitMutWith, VisitWith, noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith,
}; };
use crate::option::CompressOptions; use crate::option::CompressOptions;
@ -91,7 +91,7 @@ impl InfoMarker<'_> {
} }
impl VisitMut for InfoMarker<'_> { impl VisitMut for InfoMarker<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_call_expr(&mut self, n: &mut CallExpr) { fn visit_mut_call_expr(&mut self, n: &mut CallExpr) {
n.visit_mut_children_with(self); n.visit_mut_children_with(self);
@ -234,7 +234,7 @@ struct InfoCollector<'a> {
} }
impl Visit for InfoCollector<'_> { impl Visit for InfoCollector<'_> {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_export_decl(&mut self, f: &ExportDecl) { fn visit_export_decl(&mut self, f: &ExportDecl) {
f.visit_children_with(self); f.visit_children_with(self);

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use swc_common::{pass::CompilerPass, EqIgnoreSpan, Mark, SyntaxContext}; use swc_common::{pass::CompilerPass, EqIgnoreSpan, Mark, SyntaxContext};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
pub fn globals_defs( pub fn globals_defs(
defs: Vec<(Box<Expr>, Box<Expr>)>, defs: Vec<(Box<Expr>, Box<Expr>)>,
@ -35,7 +35,7 @@ impl CompilerPass for GlobalDefs {
/// We use [VisitMut] instead of [swc_ecma_visit::Fold] because it's faster. /// We use [VisitMut] instead of [swc_ecma_visit::Fold] because it's faster.
impl VisitMut for GlobalDefs { impl VisitMut for GlobalDefs {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_assign_expr(&mut self, n: &mut AssignExpr) { fn visit_mut_assign_expr(&mut self, n: &mut AssignExpr) {
let old = self.in_lhs_of_assign; let old = self.in_lhs_of_assign;

View File

@ -51,10 +51,7 @@ impl<'a> Scope<'a> {
while let Some(scope) = cur { while let Some(scope) = cur {
let mut w = scope.data.borrow_mut(); let mut w = scope.data.borrow_mut();
w.decls w.decls.entry(i.sym.clone()).or_default().insert(i.ctxt);
.entry(i.sym.clone())
.or_default()
.insert(i.ctxt);
cur = scope.parent; cur = scope.parent;
} }
@ -86,7 +83,7 @@ macro_rules! scoped {
} }
impl Visit for VarAnalyzer<'_> { impl Visit for VarAnalyzer<'_> {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_arrow_expr(&mut self, n: &ArrowExpr) { fn visit_arrow_expr(&mut self, n: &ArrowExpr) {
scoped!(self, n); scoped!(self, n);

View File

@ -3,7 +3,7 @@ use swc_atoms::JsWord;
use swc_common::{chain, Mark}; use swc_common::{chain, Mark};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::rename::{renamer, Renamer}; use swc_ecma_transforms_base::rename::{renamer, Renamer};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
pub(crate) use self::preserver::idents_to_preserve; pub(crate) use self::preserver::idents_to_preserve;
use crate::{option::MangleOptions, util::base54::Base54Chars}; use crate::{option::MangleOptions, util::base54::Base54Chars};
@ -77,7 +77,7 @@ impl LabelMangler {
} }
impl VisitMut for LabelMangler { impl VisitMut for LabelMangler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_labeled_stmt(&mut self, s: &mut LabeledStmt) { fn visit_mut_labeled_stmt(&mut self, s: &mut LabeledStmt) {
self.mangle(&mut s.label); self.mangle(&mut s.label);

View File

@ -1,7 +1,7 @@
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::find_pat_ids; use swc_ecma_utils::find_pat_ids;
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use crate::option::MangleOptions; use crate::option::MangleOptions;
@ -35,7 +35,7 @@ impl Preserver {
} }
impl Visit for Preserver { impl Visit for Preserver {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_block_stmt(&mut self, n: &BlockStmt) { fn visit_block_stmt(&mut self, n: &BlockStmt) {
let old_top_level = self.in_top_level; let old_top_level = self.in_top_level;

View File

@ -1,7 +1,7 @@
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_common::collections::AHashMap; use swc_common::collections::AHashMap;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use super::Base54Chars; use super::Base54Chars;
@ -43,7 +43,7 @@ impl PrivateNameMangler {
} }
impl VisitMut for PrivateNameMangler { impl VisitMut for PrivateNameMangler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_member_expr(&mut self, n: &mut MemberExpr) { fn visit_mut_member_expr(&mut self, n: &mut MemberExpr) {
n.obj.visit_mut_with(self); n.obj.visit_mut_with(self);

View File

@ -7,7 +7,7 @@ use swc_ecma_ast::{
CallExpr, Callee, Expr, IdentName, KeyValueProp, Lit, MemberExpr, MemberProp, Program, Prop, CallExpr, Callee, Expr, IdentName, KeyValueProp, Lit, MemberExpr, MemberProp, Program, Prop,
PropName, Str, SuperProp, SuperPropExpr, PropName, Str, SuperProp, SuperPropExpr,
}; };
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::{ use crate::{
option::ManglePropertiesOptions, option::ManglePropertiesOptions,
@ -238,7 +238,7 @@ impl Mangler<'_> {
} }
impl VisitMut for Mangler<'_> { impl VisitMut for Mangler<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_call_expr(&mut self, call: &mut CallExpr) { fn visit_mut_call_expr(&mut self, call: &mut CallExpr) {
call.visit_mut_children_with(self); call.visit_mut_children_with(self);

View File

@ -1,6 +1,6 @@
use swc_common::{util::take::Take, DUMMY_SP}; use swc_common::{util::take::Take, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::maybe_par; use crate::maybe_par;
@ -16,7 +16,7 @@ struct Merger {
} }
impl VisitMut for Merger { impl VisitMut for Merger {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, stmts: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, stmts: &mut Vec<ModuleItem>) {
let was_module = maybe_par!( let was_module = maybe_par!(

View File

@ -1,7 +1,7 @@
use swc_common::util::take::Take; use swc_common::util::take::Take;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::{Parallel, ParallelExt}; use swc_ecma_transforms_base::perf::{Parallel, ParallelExt};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::{maybe_par, option::CompressOptions, LIGHT_TASK_PARALLELS}; use crate::{maybe_par, option::CompressOptions, LIGHT_TASK_PARALLELS};
@ -36,7 +36,7 @@ impl Parallel for PostcompressOptimizer<'_> {
} }
impl VisitMut for PostcompressOptimizer<'_> { impl VisitMut for PostcompressOptimizer<'_> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_export_decl(&mut self, export: &mut ExportDecl) { fn visit_mut_export_decl(&mut self, export: &mut ExportDecl) {
match &mut export.decl { match &mut export.decl {

View File

@ -2,7 +2,7 @@ use std::vec::Vec;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::{Parallel, ParallelExt}; use swc_ecma_transforms_base::perf::{Parallel, ParallelExt};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::HEAVY_TASK_PARALLELS; use crate::HEAVY_TASK_PARALLELS;
@ -26,7 +26,7 @@ impl Parallel for PrecompressOptimizer {
} }
impl VisitMut for PrecompressOptimizer { impl VisitMut for PrecompressOptimizer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_stmts(&mut self, n: &mut Vec<Stmt>) { fn visit_mut_stmts(&mut self, n: &mut Vec<Stmt>) {
self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| { self.maybe_par(*HEAVY_TASK_PARALLELS, n, |v, n| {

View File

@ -8,7 +8,7 @@ use swc_common::{
}; };
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_codegen::{text_writer::WriteJs, Emitter}; use swc_ecma_codegen::{text_writer::WriteJs, Emitter};
use swc_ecma_visit::{standard_only_visit, visit_obj_and_computed, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, visit_obj_and_computed, Visit, VisitWith};
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
@ -296,7 +296,7 @@ struct CharFreqAnalyzer<'a> {
} }
impl Visit for CharFreqAnalyzer<'_> { impl Visit for CharFreqAnalyzer<'_> {
standard_only_visit!(); noop_visit_type!(fail);
visit_obj_and_computed!(); visit_obj_and_computed!();

View File

@ -7,7 +7,7 @@ use swc_atoms::Atom;
use swc_common::{util::take::Take, Span, Spanned, DUMMY_SP}; use swc_common::{util::take::Take, Span, Spanned, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{stack_size::maybe_grow_default, ModuleItemLike, StmtLike, Value}; use swc_ecma_utils::{stack_size::maybe_grow_default, ModuleItemLike, StmtLike, Value};
use swc_ecma_visit::{standard_only_visit, visit_obj_and_computed, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, visit_obj_and_computed, Visit, VisitWith};
pub(crate) mod base54; pub(crate) mod base54;
pub(crate) mod size; pub(crate) mod size;
@ -216,7 +216,7 @@ pub(crate) struct LeapFinder {
} }
impl Visit for LeapFinder { impl Visit for LeapFinder {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_await_expr(&mut self, n: &AwaitExpr) { fn visit_await_expr(&mut self, n: &AwaitExpr) {
n.visit_children_with(self); n.visit_children_with(self);
@ -308,7 +308,7 @@ pub struct DeepThisExprVisitor {
} }
impl Visit for DeepThisExprVisitor { impl Visit for DeepThisExprVisitor {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_this_expr(&mut self, _: &ThisExpr) { fn visit_this_expr(&mut self, _: &ThisExpr) {
self.found = true; self.found = true;
@ -331,7 +331,7 @@ pub(crate) struct IdentUsageCollector {
} }
impl Visit for IdentUsageCollector { impl Visit for IdentUsageCollector {
standard_only_visit!(); noop_visit_type!(fail);
visit_obj_and_computed!(); visit_obj_and_computed!();
@ -379,12 +379,6 @@ impl Visit for IdentUsageCollector {
self.ids.insert(n.to_id()); self.ids.insert(n.to_id());
} }
fn visit_member_prop(&mut self, n: &MemberProp) {
if let MemberProp::Computed(..) = n {
n.visit_children_with(self);
}
}
fn visit_prop_name(&mut self, n: &PropName) { fn visit_prop_name(&mut self, n: &PropName) {
if let PropName::Computed(..) = n { if let PropName::Computed(..) = n {
n.visit_children_with(self); n.visit_children_with(self);
@ -399,7 +393,7 @@ pub(crate) struct CapturedIdCollector {
} }
impl Visit for CapturedIdCollector { impl Visit for CapturedIdCollector {
standard_only_visit!(); noop_visit_type!(fail);
visit_obj_and_computed!(); visit_obj_and_computed!();
@ -503,7 +497,7 @@ pub(crate) struct EvalFinder {
} }
impl Visit for EvalFinder { impl Visit for EvalFinder {
standard_only_visit!(); noop_visit_type!(fail);
visit_obj_and_computed!(); visit_obj_and_computed!();

View File

@ -10,7 +10,7 @@ use swc_ecma_minifier::{
}; };
use swc_ecma_parser::{parse_file_as_expr, parse_file_as_module, EsSyntax, Syntax}; use swc_ecma_parser::{parse_file_as_expr, parse_file_as_module, EsSyntax, Syntax};
use swc_ecma_transforms_base::resolver; use swc_ecma_transforms_base::resolver;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use testing::{assert_eq, DebugUsingDisplay}; use testing::{assert_eq, DebugUsingDisplay};
fn eval(module: &str, expr: &str) -> Option<String> { fn eval(module: &str, expr: &str) -> Option<String> {
@ -169,7 +169,7 @@ impl PartialInliner {
} }
impl VisitMut for PartialInliner { impl VisitMut for PartialInliner {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, e: &mut Expr) { fn visit_mut_expr(&mut self, e: &mut Expr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -3,7 +3,7 @@ use preset_env_base::{version::should_enable, Versions};
use swc_atoms::js_word; use swc_atoms::js_word;
use swc_common::{collections::ARandomState, DUMMY_SP}; use swc_common::{collections::ARandomState, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use super::builtin::BUILTINS; use super::builtin::BUILTINS;
@ -65,7 +65,7 @@ impl Entry {
} }
impl VisitMut for Entry { impl VisitMut for Entry {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_import_decl(&mut self, i: &mut ImportDecl) { fn visit_mut_import_decl(&mut self, i: &mut ImportDecl) {
let remove = i.specifiers.is_empty() && self.add_all(&i.src.value); let remove = i.specifiers.is_empty() && self.add_all(&i.src.value);

View File

@ -3,7 +3,7 @@ use preset_env_base::{version::should_enable, Versions};
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_common::collections::ARandomState; use swc_common::collections::ARandomState;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
pub(crate) use self::entry::Entry; pub(crate) use self::entry::Entry;
use self::{ use self::{
@ -124,7 +124,7 @@ impl UsageVisitor {
/// Detects usage of types /// Detects usage of types
impl Visit for UsageVisitor { impl Visit for UsageVisitor {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_ident(&mut self, node: &Ident) { fn visit_ident(&mut self, node: &Ident) {
node.visit_children_with(self); node.visit_children_with(self);

View File

@ -3,7 +3,7 @@ use preset_env_base::version::{should_enable, Version};
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_common::collections::ARandomState; use swc_common::collections::ARandomState;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use super::{ use super::{
builtin::{ builtin::{
@ -154,7 +154,7 @@ impl UsageVisitor {
} }
impl Visit for UsageVisitor { impl Visit for UsageVisitor {
standard_only_visit!(); noop_visit_type!(fail);
/// `[a, b] = c` /// `[a, b] = c`
fn visit_array_pat(&mut self, p: &ArrayPat) { fn visit_array_pat(&mut self, p: &ArrayPat) {

View File

@ -123,10 +123,6 @@ impl VisitMut for TsHygiene {
i.ctxt = SyntaxContext::empty(); i.ctxt = SyntaxContext::empty();
} }
fn visit_mut_jsx_member_expr(&mut self, n: &mut JSXMemberExpr) {
n.obj.visit_mut_with(self);
}
fn visit_mut_prop_name(&mut self, n: &mut PropName) { fn visit_mut_prop_name(&mut self, n: &mut PropName) {
if let PropName::Computed(n) = n { if let PropName::Computed(n) = n {
n.visit_mut_with(self); n.visit_mut_with(self);

View File

@ -4,7 +4,7 @@ use swc_common::{util::take::Take, Mark, Span, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::helper; use swc_ecma_transforms_base::helper;
use swc_ecma_utils::{is_rest_arguments, quote_ident, ExprFactory}; use swc_ecma_utils::{is_rest_arguments, quote_ident, ExprFactory};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use super::get_prototype_of; use super::get_prototype_of;
@ -65,7 +65,7 @@ macro_rules! mark_nested {
} }
impl<'a> VisitMut for SuperFieldAccessFolder<'a> { impl<'a> VisitMut for SuperFieldAccessFolder<'a> {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
// mark_nested!(fold_function, Function); // mark_nested!(fold_function, Function);
mark_nested!(visit_mut_class, Class); mark_nested!(visit_mut_class, Class);

View File

@ -6,7 +6,7 @@ use swc_ecma_utils::{
constructor::inject_after_super, default_constructor, is_literal, is_simple_pure_expr, constructor::inject_after_super, default_constructor, is_literal, is_simple_pure_expr,
private_ident, prop_name_to_member_prop, ExprFactory, ModuleItemLike, StmtLike, private_ident, prop_name_to_member_prop, ExprFactory, ModuleItemLike, StmtLike,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
/// # What does this module do? /// # What does this module do?
/// ///
@ -93,7 +93,7 @@ struct ClassFieldsUseSet {
} }
impl VisitMut for ClassFieldsUseSet { impl VisitMut for ClassFieldsUseSet {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
self.visit_mut_stmts_like(n); self.visit_mut_stmts_like(n);
@ -164,7 +164,7 @@ struct FieldsHandler {
} }
impl VisitMut for FieldsHandler { impl VisitMut for FieldsHandler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class(&mut self, _: &mut Class) { fn visit_mut_class(&mut self, _: &mut Class) {
// skip inner classes // skip inner classes
@ -268,7 +268,7 @@ struct ComputedFieldsHandler {
} }
impl VisitMut for ComputedFieldsHandler { impl VisitMut for ComputedFieldsHandler {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_class_prop(&mut self, n: &mut ClassProp) { fn visit_mut_class_prop(&mut self, n: &mut ClassProp) {
match &mut n.key { match &mut n.key {

View File

@ -2,7 +2,7 @@ use swc_atoms::JsWord;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_base::perf::Parallel;
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit_mut, visit_mut_obj_and_computed, Fold, VisitMut, VisitMutWith, as_folder, noop_visit_mut_type, visit_mut_obj_and_computed, Fold, VisitMut, VisitMutWith,
}; };
pub fn reserved_words() -> impl 'static + Fold + VisitMut { pub fn reserved_words() -> impl 'static + Fold + VisitMut {
@ -21,7 +21,7 @@ impl Parallel for EsReservedWord {
} }
impl VisitMut for EsReservedWord { impl VisitMut for EsReservedWord {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
visit_mut_obj_and_computed!(); visit_mut_obj_and_computed!();

View File

@ -12,7 +12,7 @@ use swc_ecma_transforms_base::{feature::FeatureFlag, helper_expr};
use swc_ecma_utils::{ use swc_ecma_utils::{
member_expr, private_ident, quote_ident, quote_str, ExprFactory, FunctionFactory, IsDirective, member_expr, private_ident, quote_ident, quote_str, ExprFactory, FunctionFactory, IsDirective,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
pub use super::util::Config as InnerConfig; pub use super::util::Config as InnerConfig;
use crate::{ use crate::{
@ -135,7 +135,7 @@ impl<C> VisitMut for Amd<C>
where where
C: Comments, C: Comments,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module(&mut self, n: &mut Module) { fn visit_mut_module(&mut self, n: &mut Module) {
if self.module_id.is_none() { if self.module_id.is_none() {

View File

@ -7,7 +7,7 @@ use swc_ecma_transforms_base::{feature::FeatureFlag, helper_expr};
use swc_ecma_utils::{ use swc_ecma_utils::{
member_expr, private_ident, quote_expr, quote_ident, ExprFactory, FunctionFactory, IsDirective, member_expr, private_ident, quote_expr, quote_ident, ExprFactory, FunctionFactory, IsDirective,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
pub use super::util::Config; pub use super::util::Config;
use crate::{ use crate::{
@ -90,7 +90,7 @@ impl<C> VisitMut for Cjs<C>
where where
C: Comments, C: Comments,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module(&mut self, n: &mut Module) { fn visit_mut_module(&mut self, n: &mut Module) {
let mut stmts: Vec<ModuleItem> = Vec::with_capacity(n.body.len() + 6); let mut stmts: Vec<ModuleItem> = Vec::with_capacity(n.body.len() + 6);

View File

@ -3,7 +3,7 @@ use swc_common::collections::AHashMap;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::enable_helper; use swc_ecma_transforms_base::enable_helper;
use swc_ecma_visit::{ use swc_ecma_visit::{
as_folder, standard_only_visit, standard_only_visit_mut, Fold, Visit, VisitMut, VisitWith, as_folder, noop_visit_mut_type, noop_visit_type, Fold, Visit, VisitMut, VisitWith,
}; };
use crate::{module_decl_strip::LinkFlag, util::ImportInterop}; use crate::{module_decl_strip::LinkFlag, util::ImportInterop};
@ -30,7 +30,7 @@ pub struct ImportAnalyzer {
/// Inject required helpers methods **for** module transform passes. /// Inject required helpers methods **for** module transform passes.
impl VisitMut for ImportAnalyzer { impl VisitMut for ImportAnalyzer {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module(&mut self, module: &mut Module) { fn visit_mut_module(&mut self, module: &mut Module) {
self.visit_module(&*module); self.visit_module(&*module);
@ -38,7 +38,7 @@ impl VisitMut for ImportAnalyzer {
} }
impl Visit for ImportAnalyzer { impl Visit for ImportAnalyzer {
standard_only_visit!(); noop_visit_type!(fail);
fn visit_module_items(&mut self, n: &[ModuleItem]) { fn visit_module_items(&mut self, n: &[ModuleItem]) {
for item in n.iter() { for item in n.iter() {

View File

@ -7,7 +7,7 @@ use swc_common::{
}; };
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_utils::{find_pat_ids, private_ident, quote_ident, ExprFactory}; use swc_ecma_utils::{find_pat_ids, private_ident, quote_ident, ExprFactory};
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
use crate::{module_ref_rewriter::ImportMap, SpanCtx}; use crate::{module_ref_rewriter::ImportMap, SpanCtx};
@ -52,7 +52,7 @@ impl ModuleDeclStrip {
} }
impl VisitMut for ModuleDeclStrip { impl VisitMut for ModuleDeclStrip {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
let mut list = Vec::with_capacity(n.len()); let mut list = Vec::with_capacity(n.len());

View File

@ -1,7 +1,7 @@
use anyhow::Context; use anyhow::Context;
use swc_common::FileName; use swc_common::FileName;
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use crate::path::ImportResolver; use crate::path::ImportResolver;
@ -25,7 +25,7 @@ impl<R> VisitMut for Rewriter<R>
where where
R: ImportResolver, R: ImportResolver,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_call_expr(&mut self, e: &mut CallExpr) { fn visit_mut_call_expr(&mut self, e: &mut CallExpr) {
e.visit_mut_children_with(self); e.visit_mut_children_with(self);

View File

@ -1,5 +1,5 @@
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{noop_visit_mut_type, standard_only_visit_mut, VisitMut, VisitMutWith}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
pub struct TopLevelThis { pub struct TopLevelThis {
found: bool, found: bool,
@ -19,7 +19,7 @@ where
} }
impl VisitMut for TopLevelThis { impl VisitMut for TopLevelThis {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
noop_visit_mut_type!(visit_mut_function, Function); noop_visit_mut_type!(visit_mut_function, Function);

View File

@ -9,7 +9,7 @@ use swc_ecma_transforms_base::{feature::FeatureFlag, helper_expr};
use swc_ecma_utils::{ use swc_ecma_utils::{
is_valid_prop_ident, private_ident, quote_ident, quote_str, ExprFactory, IsDirective, is_valid_prop_ident, private_ident, quote_ident, quote_str, ExprFactory, IsDirective,
}; };
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use self::config::BuiltConfig; use self::config::BuiltConfig;
pub use self::config::Config; pub use self::config::Config;
@ -107,7 +107,7 @@ impl<C> VisitMut for Umd<C>
where where
C: Comments, C: Comments,
{ {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module(&mut self, module: &mut Module) { fn visit_mut_module(&mut self, module: &mut Module) {
let module_items = &mut module.body; let module_items = &mut module.body;

View File

@ -17,7 +17,7 @@ use swc_common::{
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_parser::parse_file_as_expr; use swc_ecma_parser::parse_file_as_expr;
use swc_ecma_utils::drop_span; use swc_ecma_utils::drop_span;
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
pub fn const_modules( pub fn const_modules(
cm: Lrc<SourceMap>, cm: Lrc<SourceMap>,
@ -93,7 +93,7 @@ struct Scope {
} }
impl VisitMut for ConstModules { impl VisitMut for ConstModules {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) { fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
*n = n.take().move_flat_map(|item| match item { *n = n.take().move_flat_map(|item| match item {

View File

@ -3,7 +3,7 @@
use std::{fmt::Debug, mem::forget}; use std::{fmt::Debug, mem::forget};
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_visit::{noop_visit_type, standard_only_visit, Visit, VisitWith}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
/// Assert in debug mode. This is noop in release build. /// Assert in debug mode. This is noop in release build.
pub fn debug_assert_valid<N>(node: &N) pub fn debug_assert_valid<N>(node: &N)
@ -29,7 +29,7 @@ impl Drop for Ctx<'_> {
pub struct AssertValid; pub struct AssertValid;
impl Visit for AssertValid { impl Visit for AssertValid {
standard_only_visit!(); noop_visit_type!(fail);
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
fn visit_expr(&mut self, n: &Expr) { fn visit_expr(&mut self, n: &Expr) {

View File

@ -6,7 +6,7 @@ use swc_common::{
use swc_ecma_ast::*; use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::{ParVisitMut, Parallel}; use swc_ecma_transforms_base::perf::{ParVisitMut, Parallel};
use swc_ecma_utils::{collect_decls, parallel::cpu_count, NodeIgnoringSpan}; use swc_ecma_utils::{collect_decls, parallel::cpu_count, NodeIgnoringSpan};
use swc_ecma_visit::{as_folder, standard_only_visit_mut, Fold, VisitMut, VisitMutWith}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
/// The key will be compared using [EqIgnoreSpan::eq_ignore_span], and matched /// The key will be compared using [EqIgnoreSpan::eq_ignore_span], and matched
/// expressions will be replaced with the value. /// expressions will be replaced with the value.
@ -63,7 +63,7 @@ impl Parallel for InlineGlobals {
} }
impl VisitMut for InlineGlobals { impl VisitMut for InlineGlobals {
standard_only_visit_mut!(); noop_visit_mut_type!(fail);
fn visit_mut_expr(&mut self, expr: &mut Expr) { fn visit_mut_expr(&mut self, expr: &mut Expr) {
if let Expr::Ident(Ident { ref sym, ctxt, .. }) = expr { if let Expr::Ident(Ident { ref sym, ctxt, .. }) = expr {

Some files were not shown because too many files have changed in this diff Show More