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
Integrate Polyfill.io #273
Comments
I love this @eduardoboucas and would like to see a proof of concept, so please proceed. |
This talent I have of creating more work for myself never lets me down. I shall proceed! 🚀 |
I’ve been looking into polyfill.io recently too, but I ended up thinking: since it doesn’t completely replace transpiling (e.g. with Babel), what’s the real value? I can use babel-polyfill to get the same result as part of the build process. Or am I missing something? |
@orinocai I think transpilation and polyfilling should be separate processes. For example, with Publish we're transpiling ES6 to ES5 at build stage with Babel, but the resulting bundle still includes ES5 code that isn't supported by some browsers (like And yes, you could add polyfills for these at build stage, but you'd be increasing the size of the bundle for everyone. Also, you're assuming that everyone that needs to add polyfills will also have a transpiler, which may not be the case. |
@eduardoboucas Yep, fair enough. I still think if you’re going to transpile then the added polyfills would be a minimal size increase to the bundle, but I’m totally with you on the last point. |
@orinocai Would you find it useful if CDN could also take care of transpiling? |
I’ve not yet had an opportunity to use CDN in production, but in theory yes, @eduardoboucas. It would be amazing if CDN could transpile JS and also CSS with something like http://cssnext.io |
Just a quick note to say that I really want to see this one being built. Perhaps this could be CDN 3.1, which we could tackle after API ACL? One to discuss in the next call. 📞 |
Polyfill.io is a really interesting polyfill-as-a-service open-source project. The idea is that it serves polyfills to specific JavaScript features only if the browser of the user requesting them doesn't already support them natively. For example, check https://cdn.polyfill.io/v2/polyfill.js?features=fetch on a modern browser (one that supports
fetch
) and you'll see that no JS is served.This has two major benefits over including polyfills manually:
The code behind Polyfill.io is available on GitHub and even though it can work as a standalone server, it can also be used as a Node.js module.
My think is that we could use it to extend CDN with the ability to automatically polyfill JS files. So you'd serve your JS file with modern code and CDN would inject any necessary polyfills depending on the client's browser.
I'm happy to have a stab at this if we think it's worth pursuing.
The text was updated successfully, but these errors were encountered: