|
| 1 | +/** |
| 2 | + * Polyfills enable javascript features in web browsers that do not support |
| 3 | + * the feature. Learn more: https://en.wikipedia.org/wiki/Polyfill_(programming) |
| 4 | + * |
| 5 | + * Depending on which browsers you are targeting with your app you may want |
| 6 | + * to adjust which polyfills you are using. |
| 7 | + * |
| 8 | + * If you need other polyfills such as babel-polyfill or babel-runtime |
| 9 | + * you can add it to this file. |
| 10 | + * |
| 11 | + */ |
| 12 | + |
| 13 | +// Enables Promise, support in legacy browsers such as IE11 and below |
| 14 | +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise |
| 15 | +if (typeof Promise === 'undefined') { |
| 16 | + // Rejection tracking prevents a common issue where React gets into an |
| 17 | + // inconsistent state due to an error, but it gets swallowed by a Promise, |
| 18 | + // and the user has no idea what causes React's erratic future behavior. |
| 19 | + require('promise/lib/rejection-tracking').enable(); |
| 20 | + window.Promise = require('promise/lib/es6-extensions.js'); |
| 21 | +} |
| 22 | + |
| 23 | +// Enables fetch() polyfill for making API calls support in |
| 24 | +// legacy browsers such as IE11 and below |
| 25 | +// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API |
| 26 | +require('whatwg-fetch'); |
| 27 | + |
| 28 | +// Object.assign() is commonly used with React. |
| 29 | +// It will use the native implementation if it's present and isn't buggy. |
| 30 | +// It's not supported in legacy browsers such as IE11 and below. |
| 31 | +// In some cases you can remove it even if you are targeting IE by using |
| 32 | +// Spread opertor syntax instead. |
| 33 | +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator |
| 34 | +Object.assign = require('object-assign'); |
0 commit comments