Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to target browsers with es6 support? #942

Open
torotil opened this issue Mar 31, 2022 · 4 comments
Open

How to target browsers with es6 support? #942

torotil opened this issue Mar 31, 2022 · 4 comments

Comments

@torotil
Copy link

torotil commented Mar 31, 2022

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 to defaults)
  • defaults and supports es6 and supports async-functions → fails with an error 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?

@rschristian
Copy link
Collaborator

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.

@torotil
Copy link
Author

torotil commented Mar 31, 2022

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?

@rschristian
Copy link
Collaborator

rschristian commented Mar 31, 2022

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.

@torotil
Copy link
Author

torotil commented Mar 31, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants