Closed sedubois closed 7 years ago
This is discussed in https://github.com/MatAtBread/nodent/issues/68 - the solution is to specify the compiler option wrapAwait
.
Not being a Babel expert, I can't say for sure that the es2015 preset is problematic. A quick read through the issues here and in https://github.com/MatAtBread/nodent/issues/ indicates a number of people have successfully used them together. I have a suspicion the trick is to apply 'fast-async' before the other presets.
Let me know how you get on as I know other people would like a definitive guide.
Thanks I passed on the info over here: https://github.com/zeit/next.js/issues/851#issuecomment-276014739
You're welcome. Oh, and as of fast-async 6.2.0 (if I remember correctly), the option "spec": true
sets the flags to be the most compatible with the spec. Combine with the "es6target": true
if you're running on a platform that handles arrow functions.
{
"plugins": [
["fast-async", {
"spec":true
}]
]
}
@matAtWork idea: you could release your own es2015-fast-async
preset with all the best default options and everything working OOTB :)
Not being a babel expert, I don't really feel qualified to maintain it properly, but I think others have had the same idea, see https://www.npmjs.com/package/babel-plugin-fast-async and the various presets in https://www.npmjs.com/browse/depended/fast-async
If anyone does come up with a definitive preset or guide on using fast-async with the various Babel presets, please feel free to generate a PR for the README!
@sedubois - In the absence of anything to fix here, I'll close this issue. Feel free to re-open if you need any more help.
The idea to use fast-async in Next.js came up, but there were these concerns:
fast-async
doesn't support callingawait
on normal functions that don't return a Promise. So if you, for example make a component which has astatic getInitialProps
instead ofstatic async getInitialProps
it will failIs that accurate? If these limitations do exist, is there a possibility/plan to address them? How do other users circumvent them?