Sunday, 27 July, 2014 UTC


Summary

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!