Open torotil opened 2 years ago
I’ve looked at browser support for ES6 + async/await
What's your intended target? ES6 or ES2017? async
/await
is an ES2017 feature, not ES6/ES2015.
If you want ES2017, that's our modern
output, see: https://github.com/developit/microbundle#-modern-mode-
No config needed, it's one of the default outputs.
Ah nice! There is still the problem that I can either import regenerator-runtime
or not. If I do it’s also included in the modern output. Can I avoid that somehow?
Why do you need regenerator?
Edit: If the issue is that the built code is referring to it, you likely still have a babel or browserslist config that's getting picked up and caused unwanted transforms.
The code is using both async/await as well as generator functions (yield *
).
Ah, I see. The problem only arises because I wanted both the .js
and the .modern.js
output to be usable. My idea was to have both ready and decide on a case by case basis which to use. If I ignore the .js
output then I can simply not import regenerator-runtime
and have a .modern.js
without it.
I’ve looked at browser support for ES6 + async/await for our sites and as it looks transpiling to ES5 might not be worth it. It makes less than 1% difference in browser coverage. As a test I tried to find a browserslist config that allows this.
So far I’ve tried:
defaults and supports es6
→ Still transpiles to ES5 (output is identical todefaults
)defaults and supports es6 and supports async-functions
→ fails with anerror unknown Statement of type "ForOfStatement"
which might be some Babel bug.Is there a way to use microbundle to bundle and minify JS and still have ES6 output?