shell
npm install -g babel-cli
mkdir my-babel-plugin
cd my-babel-plugin
shell
npm init -y
shell
npm install --save @babel/core @babel/preset-env
script
const { types: t } = require("@babel/core");
const { createMacro } = require("babel-plugin-macros");
function exampleMacro({ references, state, babel }) {
references.default.forEach(referencePath => {
});
}
module.exports = createMacro(exampleMacro);
json
{
"presets": ["@babel/preset-env"],
"plugins": ["./plugin.js"]
}
script
foobar();
shell
babel test.js