Plugin Options" class="reference-link">Plugin Options
These options then get passed into plugin visitors through the object:
export default function({ types: t }) {
return {
visitor: {
FunctionDeclaration(path, state) {
console.log(state.opts);
}
}
}
Plugins can have functions that are run before or after plugins. They can be used for setup or cleanup/analysis purposes.
export default function({ types: t }) {
return {
inherits: require("babel-plugin-syntax-jsx")
};
If you want to throw an error with babel-code-frame and a message:
7 |
8 | let tips = [
> 9 | "Click on any AST node with a '+' to expand it",
| ^
10 |
11 | "Hovering over a node highlights the \
12 | corresponding part in the source code",