瀏覽代碼

Replace object-assign and promise polyfills with core-js

Thibaud Colas 7 年之前
父節點
當前提交
1eb38a8b7c
共有 3 個文件被更改,包括 11 次插入30 次删除
  1. 2 17
      client/src/utils/polyfills.js
  2. 8 11
      package-lock.json
  3. 1 2
      package.json

+ 2 - 17
client/src/utils/polyfills.js

@@ -1,21 +1,6 @@
-/* eslint-disable global-require */
-
 /**
  * Polyfills for Wagtail's admin.
- * Heavily inspired from https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/polyfills.js.
  */
 
-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();
-  window.Promise = require('promise/lib/es6-extensions.js');
-}
-
-// fetch() polyfill for making API calls.
-require('whatwg-fetch');
-
-// Object.assign() is commonly used with React.
-// It will use the native implementation if it's present and isn't buggy.
-Object.assign = require('object-assign');
+import 'core-js';
+import 'whatwg-fetch';

+ 8 - 11
package-lock.json

@@ -1988,9 +1988,9 @@
       "dev": true
     },
     "core-js": {
-      "version": "1.2.7",
-      "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
-      "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
+      "version": "2.5.3",
+      "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz",
+      "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4="
     },
     "core-util-is": {
       "version": "1.0.2",
@@ -3450,6 +3450,11 @@
         "ua-parser-js": "0.7.17"
       },
       "dependencies": {
+        "core-js": {
+          "version": "1.2.7",
+          "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
+          "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
+        },
         "promise": {
           "version": "7.3.1",
           "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
@@ -10678,14 +10683,6 @@
       "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=",
       "dev": true
     },
-    "promise": {
-      "version": "8.0.1",
-      "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz",
-      "integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=",
-      "requires": {
-        "asap": "2.0.6"
-      }
-    },
     "prop-types": {
       "version": "15.6.0",
       "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.0.tgz",

+ 1 - 2
package.json

@@ -69,12 +69,11 @@
     "webpack": "^3.10.0"
   },
   "dependencies": {
+    "core-js": "^2.5.3",
     "draft-js": "^0.10.4",
     "draftail": "^0.12.0",
     "focus-trap-react": "^3.1.0",
     "lodash": "^4.17.4",
-    "object-assign": "^4.1.1",
-    "promise": "^8.0.1",
     "prop-types": "^15.6.0",
     "react": "^16.2.0",
     "react-dom": "^16.2.0",