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

Runtime polyfilling with feature detection #9170

Open
askbeka opened this issue Dec 12, 2018 · 1 comment
Open

Runtime polyfilling with feature detection #9170

askbeka opened this issue Dec 12, 2018 · 1 comment

Comments

@askbeka
Copy link

askbeka commented Dec 12, 2018

Feature Request

When using preset-env with useBuilitins: 'usage', we can create bundles to serve target browsers, But modern browsers, that do not need polyfills will still load them, to solve that we can run babel with different preset options, for each browser, but it is not ideal, because server needs to know which browser is being used, and which bundle to serve, issues can happen when unknown browser is being used.

And there is polyfill.io which also requires getting them from outside, running the tool internally. So those solutions are more complicated in practice, since they involve changes in infrastructure in companies.

But I think we already have tools to achieve build time solution.

To solve that babel could provide way to get list of applied polyfills, along with and generate loader script that can be included in application to apply
For example pseudo code:

var listOfPolyfillsUsed = ['Array.prototype.includes', 'Array.prototype.find']
var listOfPolyfillsToApply = listOfPolyfillsUsed.filter(...);

loadScript('polyfills-' + listOfPolyfillsToApply.join('-') + '.js');
@babel-bot
Copy link
Collaborator

Hey @askbeka! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

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

No branches or pull requests

2 participants