A few more words on Acorn-JSX

Posted on:

Initially this was part of my email response to Lou Husson after mentioning Acorn-JSX in Facebook React Community Round-up #20 and reaching me out, but decided that someone else might find it useful too.

UPD (June 12, 2015): Facebook deprecates own parsing and transformation tools in favor of Acorn, Acorn-JSX and Babel. Looks like I'll need to be more careful about updates starting from now 😜

As for today, I’ve developed complete ES6 support for Acorn (as far as it can be complete in such a dynamic world; anyway it contains even newest specs than Esprima supports). So I’ve merged it to Acorn-JSX; also I’ve added spread attribute support (<div {…attr} />), took all the tests from official parser, adapted them for Acorn test runner - and it passes them all. So caveat about different syntax level supported in my and official parser was removed, and “official parser is maintained by authors of React.js itself, so it's recommended to be used in production” was left as the only reason for not using it.

Everything else works in the same way. Just 2x faster.

Also wanted to notice that it’s not the only tool for JSX AST I’ve worked on, so maybe you find following one useful as well. Earlier from unworking recast-based fork I’ve developed very simple JSX transpiler based on official Esprima-FB parser, own JSX-enabling drop-in for Estraverse and Escodegen AST tools. It allows you to either 1) parse JSX to AST with attached comments (supported in official Esprima, but not in Esprima-FB), 2) convert it directly to code + source map or 3) use as browserify transformer plugin.

Stay tuned for updates about new JS(X) AST tools!

More posts: