Tuesday, 24 July 2018

Babel 6 with just JSX transform and no other transforms

I want to use babel-plugin-transform-jsx, but no other transforms on some JSX files with some Javascript currently considered at stage 3 i.e. candidates.

Transpilation fails with a Syntax Error if those JSX files contain:

  1. rest spread operators {...x, ...y}
  2. async generators async function * () {}

The objective is to improve debug-ability of code in a modern browser, since the Babel transpilation of async generators in particular seems to break the dev tools for Chrome, Firefox i.e. breakpoints stop working, references to this fail, debugger calls are skipped, and numerous other observed problems.

There seems to be no alternative to using Babel to generate JSX in the above form — which works fine; an ideal solution would be to just have Babel ignore the async generators and rest-spread operators (and any other code it'd otherwise throw a syntax error on).



from Babel 6 with just JSX transform and no other transforms

No comments:

Post a Comment