简体   繁体   中英

Switching from babel-polyfill to core-js in React app

I use babel-polyfill in my React app to transpile ECMAScript to vanilla JS . I understand babel-polyfill is now deprecated.

The warning I get in my React app is:

@babel/polyfill is deprecated. Please, use required parts of core-js and regenerator-runtime/runtime separately

I currently have the following in my package.json file:

"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 ?

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

Also, I think, instead of 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? Am I missing anything?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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