Procházet zdrojové kódy

build: remove `@babel/polyfill` in favor of `core-js@3` (#3025)

Also removes Babel plugin that have been merged in `@babel/preset-env`
from our dependencies.

Also switch back to the default value for the `modules` options:

> Setting this to false will preserve ES modules. Use this only if you
> intend to ship native ES Modules to browsers. If you are using a
> bundler with Babel, the default modules: "auto" is always preferred.

Refs: https://babel.dev/docs/en/babel-preset-env#options
Refs: https://github.com/zloirock/core-js/blob/HEAD/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md
Antoine du Hamel před 3 roky
rodič
revize
823453a3d6
4 změnil soubory, kde provedl 7 přidání a 49 odebrání
  1. 3 3
      babel.config.js
  2. 2 1
      bin/build-bundle.js
  3. 1 41
      package-lock.json
  4. 1 4
      package.json

+ 3 - 3
babel.config.js

@@ -7,14 +7,14 @@ module.exports = (api) => {
   return {
     presets: [
       ['@babel/preset-env', {
-        modules: false,
         loose: true,
         targets,
+        useBuiltIns: false, // Don't add polyfills automatically.
+        // We can uncomment the following line if we start adding polyfills to the non-legacy dist files.
+        // corejs: { version: '3.15', proposals: true },
       }],
     ],
     plugins: [
-      ['@babel/plugin-proposal-class-properties', { loose: true }],
-      '@babel/plugin-transform-object-assign',
       ['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
       process.env.IS_RELEASE_BUILD && 'babel-plugin-inline-package-json',
     ].filter(Boolean),

+ 2 - 1
bin/build-bundle.js

@@ -64,9 +64,10 @@ async function transpileDownForIE ([bundleFile, standalone]) {
 
     browserslistEnv: 'legacy',
     presets: [['@babel/preset-env',  {
-      modules: false,
       loose: true,
       targets: { ie:11 },
+      useBuiltIns: 'entry',
+      corejs: { version: '3.15', proposals: true },
     }]],
   })
   const { code, map } = await minify(js, {

+ 1 - 41
package-lock.json

@@ -21,10 +21,7 @@
         "@babel/core": "^7.14.6",
         "@babel/eslint-parser": "^7.11.3",
         "@babel/eslint-plugin": "^7.11.3",
-        "@babel/plugin-proposal-class-properties": "^7.10.4",
-        "@babel/plugin-transform-object-assign": "^7.10.4",
         "@babel/plugin-transform-react-jsx": "^7.10.4",
-        "@babel/polyfill": "^7.10.4",
         "@babel/preset-env": "^7.14.7",
         "@babel/register": "^7.10.5",
         "@goto-bus-stop/envify": "^5.0.0",
@@ -45,7 +42,7 @@
         "browserify": "^17.0.0",
         "chalk": "^4.1.1",
         "concat-stream": "^2.0.0",
-        "core-js": "^3.15.2",
+        "core-js": "~3.15.2",
         "cssnano": "^5.0.6",
         "dedent": "^0.7.0",
         "deep-freeze": "^0.0.1",
@@ -4440,25 +4437,6 @@
         "@babel/core": "^7.0.0-0"
       }
     },
-    "node_modules/@babel/polyfill": {
-      "version": "7.12.1",
-      "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.12.1.tgz",
-      "integrity": "sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g==",
-      "deprecated": "🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.",
-      "dev": true,
-      "dependencies": {
-        "core-js": "^2.6.5",
-        "regenerator-runtime": "^0.13.4"
-      }
-    },
-    "node_modules/@babel/polyfill/node_modules/core-js": {
-      "version": "2.6.12",
-      "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
-      "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
-      "deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
-      "dev": true,
-      "hasInstallScript": true
-    },
     "node_modules/@babel/preset-env": {
       "version": "7.14.7",
       "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.7.tgz",
@@ -79775,24 +79753,6 @@
         "@babel/helper-plugin-utils": "^7.14.5"
       }
     },
-    "@babel/polyfill": {
-      "version": "7.12.1",
-      "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.12.1.tgz",
-      "integrity": "sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g==",
-      "dev": true,
-      "requires": {
-        "core-js": "^2.6.5",
-        "regenerator-runtime": "^0.13.4"
-      },
-      "dependencies": {
-        "core-js": {
-          "version": "2.6.12",
-          "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
-          "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
-          "dev": true
-        }
-      }
-    },
     "@babel/preset-env": {
       "version": "7.14.7",
       "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.7.tgz",

+ 1 - 4
package.json

@@ -39,10 +39,7 @@
     "@babel/core": "^7.14.6",
     "@babel/eslint-parser": "^7.11.3",
     "@babel/eslint-plugin": "^7.11.3",
-    "@babel/plugin-proposal-class-properties": "^7.10.4",
-    "@babel/plugin-transform-object-assign": "^7.10.4",
     "@babel/plugin-transform-react-jsx": "^7.10.4",
-    "@babel/polyfill": "^7.10.4",
     "@babel/preset-env": "^7.14.7",
     "@babel/register": "^7.10.5",
     "@goto-bus-stop/envify": "^5.0.0",
@@ -63,7 +60,7 @@
     "browserify": "^17.0.0",
     "chalk": "^4.1.1",
     "concat-stream": "^2.0.0",
-    "core-js": "^3.15.2",
+    "core-js": "~3.15.2",
     "cssnano": "^5.0.6",
     "dedent": "^0.7.0",
     "deep-freeze": "^0.0.1",