yoyo837 7 лет назад
Родитель
Сommit
fce74f92ce
3 измененных файлов с 15 добавлено и 3 удалено
  1. 2 1
      package.json
  2. 1 2
      src/index.js
  3. 12 0
      src/polyfill.js

+ 2 - 1
package.json

@@ -45,14 +45,15 @@
     "react-dom": "^16.4.1",
     "react-fittext": "^1.0.0",
     "rollbar": "^2.3.4",
+    "setprototypeof": "^1.1.0",
     "url-polyfill": "^1.0.10"
   },
   "devDependencies": {
     "babel-eslint": "^8.1.2",
     "babel-plugin-dva-hmr": "^0.4.1",
     "babel-plugin-import": "^1.6.7",
-    "babel-plugin-transform-decorators-legacy": "^1.3.4",
     "babel-plugin-module-resolver": "^3.1.1",
+    "babel-plugin-transform-decorators-legacy": "^1.3.4",
     "cross-env": "^5.1.1",
     "cross-port-killer": "^1.0.1",
     "enzyme": "^3.1.0",

+ 1 - 2
src/index.js

@@ -1,5 +1,4 @@
-import '@babel/polyfill';
-import 'url-polyfill';
+import './polyfill';
 import dva from 'dva';
 
 import createHistory from 'history/createHashHistory';

+ 12 - 0
src/polyfill.js

@@ -0,0 +1,12 @@
+import '@babel/polyfill';
+import 'url-polyfill';
+import setprototypeof from 'setprototypeof';
+
+// React depends on set/map/requestAnimationFrame
+// https://reactjs.org/docs/javascript-environment-requirements.html
+// import 'core-js/es6/set';
+// import 'core-js/es6/map';
+// import 'raf/polyfill'; 只兼容到IE10不需要,况且fetch的polyfill whatwg-fetch也只兼容到IE10
+
+// https://github.com/umijs/umi/issues/413
+Object.setPrototypeOf = setprototypeof;