Using webpack with shims and polyfills08 Apr 2015
The overall browser support is starting to pick up, with Chrome 42(beta), Firefox 39 and Opera 29 all shipping with it by default. Internet Explorer is currently listing it as “under consideration” on their platform status page.
Luckily for us GitHub has been maintaining a great polyfill github/fetch since October 2014, which means we can already use this in production. Using the polyfill without a bundler like webpack would mean adding a
<script> tag to your template.
I couldn’t figure out the “webpack way” of including the polyfill in my bundle, and after reading the webpack wiki page on shimming modules I still couldn’t quite figure out the syntax.
The important part of the webpack config:
For more information about shimming modules in webpack, checkout the documentation.
Update 1: Corrected small typo spotted by @stkhlm, thanks!
Update 2: Updated
npm install to use
devDependencies, thanks to Gio d’Amelio!