Babel Plugin Handbook
AST Explorer
Babel Plugin Playground
Plugin Code
var template = require("babel-template") module.exports = function(babel) { return { visitor: { BinaryExpression(path){ if (path.node.operator === "*"){ var call = babel.types.callExpression( babel.types.identifier("multiply"), [path.node.left, path.node.right] ) path.replaceWith(call) } } } } }
Uncompiled Code
var square = n => n * n
Compiled code