Babel provides APIs so that anyone can create a preset and plugin of their own.
Babel plugin changes a code based on AST(Abstract Syntax Tree). Therefore, you have to know the structure of AST in order to create your own plugin
you can found the full code on github
Basic structure of a babel plugin
types parametertypes parameter to make a nodetypes node is used to check the tyoe of the AST nodeA babel plugin to remove console.log’s
console.log('asdf');ExpressionStatement nodeCallExpression nodeMemberExpression node inside the CallExpression node calls a methodMemberExpression node has the information about the object and the methodA babel plugin to add console.log’s
FunctionDeclaration nodeidBlockStatement nodeconsole.log at the very beginning of the array