swc/babel/visit
강동윤 82ef06afb8
feat(babel/compat): Improve performance of babelify (#1626)
swc_babel_compat:
 - Optimize.

swc:
 - Improve performance of comment storage.
2021-05-06 14:56:54 +09:00
..
src feat(babel/compat): Improve performance of babelify (#1626) 2021-05-06 14:56:54 +09:00
Cargo.toml feat(babel/compat): Improve performance of babelify (#1626) 2021-05-06 14:56:54 +09:00
README.md feat(babel/compat): Improve performance of babelify (#1626) 2021-05-06 14:56:54 +09:00

Visitor pattern implementation for Babel AST.

Example

// Visit all Identifier nodes in the Babel AST and change the optional field to 
// Some(true) for each of them.

use swc_babel_visit::{VisitMut, VisitMutWith};
use swc_babel_ast::{Identifier, File};

struct Visitor;

impl VisitMut for Visitor {
    fn visit_mut_identifier(&mut self, node: &mut Identifier) {
        node.optional = Some(true);
    }
}

let ast: File = get_babel_ast();
let mut v = Visitor {};
ast.visit_mut_with(&mut v);