escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

feat: add jsx support

Open erquhart opened this issue 5 years ago • 5 comments

Adds JSX support.

Notes

  • Changed the general test suite to use the esprima dependency rather than 1.0.0-dev
  • Upgraded esprima from 3.1.3 to 4.0.1 for improved JSX support in tests
  • Esprima upgrade is causing tests to fail for two reasons:
    • Esprima outputs string literals with double quotes in 1.0.0, but switched to single quotes in 1.1.0 (source)
    • Esprima no longer represents the presence of a leading 0 in a decimal, so instead of "0.14" it's ".14", both for value and raw
  • Besides the above mentioned issues, tests are passing
  • JSX SpreadChild and Fragments are not supported in this PR, as support for them is not quite widespread (esprima supports neither, I'd consider that to be a decent indicator)

Todo

  • [ ] determine if any cases merit throwing an error
  • [ ] format output appropriately for compact/non-compact
  • [ ] precedence/flag usage review by a maintainer for all uses of generateExpression()

Closes #333.

erquhart avatar Apr 05 '19 22:04 erquhart

Haven't forgotten about this, will circle back soon.

erquhart avatar Apr 30 '19 17:04 erquhart

@erquhart how I can help you to finish this update?

zouxuoz avatar Jan 04 '20 14:01 zouxuoz

Just a matter of when, haven't circled back yet. An old fork (https://github.com/ng-vu/escodegen-jsx) that introduced (incompatible) jsx support had some things that felt necessary, so the plan has been to pull in the more thorough bits from there. If you want to take this across the finish line, by all means please do!

erquhart avatar Jan 07 '20 22:01 erquhart

Is JSX going to be supported or is there any other way to do it?

sag1v avatar Dec 23 '21 20:12 sag1v

What if we added this https://github.com/wallabyjs/escodegen?

smol-honk avatar Oct 27 '22 17:10 smol-honk