andreypopp/reactify

Use together with es6ify

Closed this issue · 8 comments

I'm combining this with es6ify (I didn't realize it could do ES6 transforms, too, though it seems like it would also be more limited in terms of what is supports).

es6ify and reactify have been working great together, except if I enable "traceurOverrides: asyncFunctions" because I want to use the "await" keyword. I have to run reactify first, and await doesn't get through: Parse Error: Line 18: Unexpected identifier while parsing file.

Is there something that can be done about this?

I think reactify should be first in the browserify transform pipeline. This is because Traceur can't parse JSX.

Ah, ok, you are using async/await. I think not much can be done with that atm. Closing as it's not a reactify issue.

Just to be clear, while I find gulp somewhat confusing at times, I am pretty sure I am running reactify first.

The strange thing is that reactify happily lives with all kinds of ES6 syntax, including arrow functions, but not with await.

Is the issue in the underlying Facebook transformer?

Yes, the issue is that Facebook's transformer's parser doesn't understand async/await syntax.

Hm... actually there was facebookarchive/esprima#45 merged... can you check if esprima-fb installed under react-tools/jstransform has support for async/await?

The path on my machine is:

{myproject}/node_modules/reactify/node_modules/react-tools/node_modules/commoner/node_modules/recast/node_modules/esprima-fb/esprima.js

It does contain the linked pull request. Strange.

Apologies. There is another one at the location you said:

node_modules/reactify/node_modules/jstransform/node_modules/esprima-fb/esprima.js

But it, too, knows about await. But now that I know where to look, maybe I can find something out.

Ok, problem solved. It works just fine, its just that esprima is really not very forthcoming with its error messages; I didn't declare the function where I was using the keyword as "async", and the error message in this case only says "unexpected identifier" without any clarification.

Sorry for the false alarm.