Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created January 16, 2018 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/dc2486a6f4dc6e5cc9b9ca8d7f14ce97 to your computer and use it in GitHub Desktop.
Save JoshCheek/dc2486a6f4dc6e5cc9b9ca8d7f14ce97 to your computer and use it in GitHub Desktop.
Started to go down a rabbit hole with JSX parsing, but going to stop now, y'all
const babylon = require('babylon')
const fs = require('fs')
const code = fs.readFileSync('omg.js', 'utf-8')
const ast = babylon.parse(code, {plugins: ['jsx']})
console.dir(ast.program.body, {depth: 10})
<Josh abc="123" def={this.lol}>
Some stuffs
</Josh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment