forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolyfills.js
More file actions
35 lines (30 loc) · 1.03 KB
/
polyfills.js
File metadata and controls
35 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const g = typeof window === 'undefined' ? self : window;
if (typeof Promise === 'undefined') {
// Rejection tracking prevents a common issue where React gets into an
// inconsistent state due to an error, but it gets swallowed by a Promise,
// and the user has no idea what causes React's erratic future behavior.
require('promise/lib/rejection-tracking').enable();
g.Promise = require('promise/lib/es6-extensions.js');
}
// fetch() polyfill for making API calls.
require('whatwg-fetch');
g.cosmiconfig = {};
g.prettier = {};
g.jsdom = {
JSDOM: {
// IE11 support
// eslint-disable-next-line object-shorthand
fragment: function fragment(htmlString) {
// eslint-disable-next-line no-var
var div = document.createElement('div');
div.innerHTML = htmlString.trim();
// Change this to div.childNodes to support multiple top-level nodes
return div;
},
},
};
// IE11
require('core-js/fn/array/find');
require('core-js/fn/array/from');
require('core-js/fn/object/assign');
require('core-js/fn/symbol');