Closed trusktr closed 6 years ago
Alright, I got it to work by having a first babel pass compile async functions with fast-async, then the second pass ponyfills the Promises with transform-runtime.
However, the Zousan promise polyfill is still in the code base. I suppose I might as well use it then.
Would be great if you could figure a way to trim out the unused polyfill and use the one Babel already provides!
babel 440ms - 1.8x slower
Nevermind! I'll take Nodent's then.
I could create an option to allow you to specify the global symbol to be used instead of "Promise", but I've not had a realistic use-case to date where it matters. Zousan is pretty fast anyway :)
Closing as no action to take. Please re-open if you have a recommendation on how to progress this.
babel-transform-runtime
transpilesPromise
in source code to_Promise
which is ultimately thePromise
polyfill fromcore-js
.Is it possible to make
fast-async
use transform-runtime promises?Currently, when I set the fast-async option
compiler.promises
to true, it result inPromise
appearing in the output.Then, I thought that if I change the ordering of plugins so that
fast-async
runs beforetransform-runtime
, thattransform-runtime
would handle thesePromise
s, but this isn't the case.transform-runtime
is leaving those in the output unpolyfilled. If I try swapping the order of the two plugins, no luck.If I set
compiler.promises
to false, then I see Nodent's Promise polyfill included (which is extra duplication).A possible workaround could be that I can have a separate Babel step using only
fast-async
to convert async functions on first pass withpromises: true
, then the second pass of Babel would catch those Promises. This will obviously take more time, but the output will be better (I think?).