简体   繁体   English

在 React 应用程序中从 babel-polyfill 切换到 core-js

[英]Switching from babel-polyfill to core-js in React app

I use babel-polyfill in my React app to transpile ECMAScript to vanilla JS .我在我的React应用程序中使用babel-polyfill polyfill 将ECMAScript转换为 vanilla JS I understand babel-polyfill is now deprecated.我知道babel-polyfill现在已被弃用。

The warning I get in my React app is:我在React应用程序中收到的警告是:

@babel/polyfill is deprecated. @babel/polyfill 已弃用。 Please, use required parts of core-js and regenerator-runtime/runtime separately请分别使用 core-js 和 regenerator-runtime/runtime 的必需部分

I currently have the following in my package.json file:我目前在我的package.json文件中有以下内容:

"devDependencies": {
    "babel-polyfill": "^6.26.0",
    "redux-devtools": "^3.5.0"
  }

Is it safe to assume that I'll need to have the following now instead of babel-polyfill ?可以安全地假设我现在需要以下内容而不是babel-polyfill吗?

"devDependencies": {
    "core-js": "3.6.5",
    "regenerator-runtime": "0.13.5"
  },

Also, I think, instead of import 'babel-polyfill';另外,我认为,而不是import 'babel-polyfill'; in my reducers and components, I think I'll need the following:在我的减速器和组件中,我想我需要以下内容:

import "core-js/stable";
import "regenerator-runtime/runtime";

Are these the steps to go through?这些是通过 go 的步骤吗? Am I missing anything?我错过了什么吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM