You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why does Babel transpile async functions to generators via _asyncToGenerator if target supports async/await?
Originally posted by nlucero November 1, 2021
I'm trying to understand why my transpiled code transforms regular async functions to generators via _asyncToGenerator if the compilation target already supports async functions.
I'm using @babel/preset-env and targeting node>=16.0.0 via targets. This is my config file:
This seems unnecessary to me since my transpilation target (node v16.x.x) fully supports async functions. Is there a good reason why this is being done this way? Could it be a misconfiguration on my end?
For more context, the transpiled code uses native async functions (no _asyncToGenerator whatsoever) if I set my target to node>=14.0.0, so this might be a regression introduced recently.
The text was updated successfully, but these errors were encountered:
When targeting node 16.0.0, Babel complains that it's not a known Node.js version. When targeting node >=14.0.0, Babel doesn't transpile async functions.
Discussed in #13912
Why does
Babel
transpile async functions to generators via_asyncToGenerator
if target supports async/await?Originally posted by nlucero November 1, 2021
I'm trying to understand why my transpiled code transforms regular async functions to generators via
_asyncToGenerator
if the compilation target already supports async functions.I'm using
@babel/preset-env
and targetingnode
>=16.0.0
viatargets
. This is my config file:If I inspect my transpiled code, I see my async functions are transpiled to something like this:
This seems unnecessary to me since my transpilation target (
node v16.x.x
) fully supports async functions. Is there a good reason why this is being done this way? Could it be a misconfiguration on my end?For more context, the transpiled code uses native
async
functions (no_asyncToGenerator
whatsoever) if I set my target to node>=14.0.0, so this might be a regression introduced recently.The text was updated successfully, but these errors were encountered: