reluxscript 0.1.4

Write AST transformations once. Compile to Babel, SWC, and beyond.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// A simple plugin that removes console.log statements
plugin ConsoleStripper {
    fn visit_call_expression(node: &mut CallExpression, ctx: &Context) {
        // Check if this is a console.log call
        if matches!(node.callee, MemberExpression {
            object: Identifier { name: "console" },
            property: Identifier { name: "log" }
        }) {
            // Remove the call by replacing with undefined
            *node = CallExpression {
                callee: Identifier { name: "void" },
                arguments: vec![Literal { value: 0 }],
            };
        }

        node.visit_children(self);
    }
}