1. 17
    Polyfill Promises for Webpack 2
    1m 59s
⚠️ This lesson is retired and might contain outdated information.

Polyfill Promises for Webpack 2

Kent C. Dodds
InstructorKent C. Dodds
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 2 years ago

If you're going to use code splitting with Webpack 2, you'll need to make sure the browser has support for the ES6 Promise API. This means that if you are required to support an old browser, you need to provide a polyfill. Polyfilling is relatively trivial to do with Webpack, but because Webpack itself depends on this particular polyfill, you have to come up with another way of doing so. In this lesson, we'll see how we can use the polyfill.io service to automatically polyfill this API (and others) for us.

Dean
Dean
~ 8 years ago

Really awesome series. I have a question ---

I 'might' need code splitting, BUT, my application only cares about IE11+, and more recent versions of the other browsers. Plus, I am using babel etc... so, is the polyfill still required for code splitting? After re-watching the video, it seems that webpack needs it no matter what -- but why wouldn't webpack include one of its own as it seems rather dangerous to hinge a build process on a third party script - Your thoughts?

Kent C. Dodds
Kent C. Doddsinstructor
~ 8 years ago

Webpack 2 just needs Promises. If it's available in the browser, you don't need the Promise polyfill. Unfortunately IE11 does not support promises. This is why the polyfill service is great. Because the promise polyfill is only sent to browsers that don't support promises natively.

You might argue that Webpack's runtime should include promises. But I would hate to send that polyfill to browsers that support it natively, especially if my app is only used by modern browsers.

Markdown supported.
Become a member to join the discussionEnroll Today