acorn-jsx-walk
JSX support for Acorn Walk
Last updated 7 years ago by jlmakes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install acorn-jsx-walk 
SYNC missed versions from official npm registry.

acorn-jsx-walk

JSX support for Acorn Walk.

Install

npm install acorn-jsx-walk

Example

// Extend Acorn parser with JSX
const acorn = require('acorn')
const jsx = require('acorn-jsx')
const parser = acorn.Parser.extend(jsx())

// Extend Acorn walk with JSX
const walk = require('acorn-walk')
const { extend } = require('acorn-jsx-walk')

extend(walk.base)

// Create AST from source containing JSX
const source = `
  const a = 2
  const fn = () => {
    const el = <div>Hello world!</div>
    return el
  }
`
const ast = parser.parse(source)

// Finally...
walk.simple(ast, {
  JSXElement(node) {
    console.log(`Found a ${node.type}!`)
  },
})

Copyright 2019 Contributors
Open source under the MIT License.
Special thanks to @sderosiaux and @adrianheine.

Current Tags

  • 2.0.0                                ...           latest (7 years ago)
  • 2.0.0-canary.6                                ...           next (8 years ago)

9 Versions

  • 2.0.0                                ...           7 years ago
  • 2.0.0-canary.6                                ...           8 years ago
  • 2.0.0-canary.5                                ...           8 years ago
  • 2.0.0-canary.4                                ...           8 years ago
  • 2.0.0-canary.3                                ...           8 years ago
  • 2.0.0-canary.2                                ...           8 years ago
  • 2.0.0-canary.1                                ...           8 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 18
Today 0
This Week 0
This Month 11
Last Day 0
Last Week 9
Last Month 0
Dependencies (0)
None
Dev Dependencies (12)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE