-
-
Notifications
You must be signed in to change notification settings - Fork 41
Incorrect result with async arrow functions when not using babel-preset-es2015
#19
Comments
Thanks for your bug report. Yes, es2015 is necessary when using ES6 functionality like arrow functions. It doesn't make much sense to duplicate all of Babel's functionality in this plugin. It compiles ES5 with async/await to ES5 with promises, and that's it. (Although it does take care to run after the es2015 preset so it can be used in conjunction with it) It might be good to clarify that somewhere in the README file. Keeping the issue open for that, PRs welcome if you want too speed that up a bit. :) |
Wait, you're running this in an ES6 environment... Yes, I would like to support that use case, but not sure how to do it. Converting arrow functions too is probably pretty doable, but e.g. doing variable hoisting which is required with let/const is more difficult than using var. So you'd still need to run the block scope plugin of babel anyway probably. Need to look into it a bit more. Why are you using kneden in this case? Because it's probably pretty hard to beat the readability of |
Yeah, you're right, I was trying to run it in an es6 environment (node 4) and use Babel + this to just compile the async/await stuff rather than everything down to es5, but I can see that gets tricky with let/const Philip Roberts
|
Ok, thought a bit more about this. It would definitely be a long-term project, and considering
|
No worries, yeah to be honest it sounds like just mentioning in the docs that you need es2015 set for this to work is probably the best solution.
Mostly cos it looked like a neat project and I figured I'd throw it at something and see how it worked :) |
Added a note to the docs, leaving this open for the outlined long term plan. |
I tried kneden out on some test files where I was previously using
babel-transform-async-to-generator
and came across a failing case.In this project I wasn't using
babel-preset-es2015
as I just wanted to compile async/await down to es6.I've simplified the test case down to this:
.babelrc
actual.js
The output I get from running the test is:
which is definitely not right :)
If I add
"presets": ["es2015"]
to .babelrc in the fixture dir I get the more correct looking:The text was updated successfully, but these errors were encountered: