Polyfills: everything you ever wanted to know, or maybe a bit less
David Gilbertson
3.1K26

“Ironically, you can’t conditionally load a promise polyfill with Webpack 2.”

Actually, you can!

The technique is explained in this article https://philipwalton.com/articles/loading-polyfills-only-when-needed/

And José Quinto wrote a little package based on that article that wraps feature detection code and do polyfill.io call only with non supported features to be polyfilled.

https://blog.josequinto.com/2017/01/20/getting-react-to-load-polyfills-only-when-needed/

I delete window.Promise; tested it with webpack’s code splitting and it works just fine!