Created
April 27, 2022 18:18
-
-
Save souporserious/51dfb3e92de6dd9f817d23a25f128b02 to your computer and use it in GitHub Desktop.
Documenting Steps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** step:01 Start with the initial plugin. */ | |
import jsx from '@babel/plugin-syntax-jsx' | |
export default () => { | |
return { | |
inherits: jsx, | |
visitor: { | |
/** step:02 Add visitor */ | |
Program() { | |
this.tree = [] | |
}, | |
JSXElement(path) { | |
this.tree.push({ | |
name: path.node.openingElement.name.name, | |
start: path.node.start, | |
end: path.node.end, | |
}) | |
}, | |
/** step:02 */ | |
}, | |
} | |
} | |
/** step:01 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment