[英]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?我错过了什么吗?
If you're using CRA, just follow the steps here:如果您使用的是 CRA,只需按照此处的步骤操作:
https://github.com/facebook/create-react-app/tree/main/packages/react-app-polyfill#polyfilling-other-language-features https://github.com/facebook/create-react-app/tree/main/packages/react-app-polyfill#polyfilling-other-language-features
Useful links: https://babeljs.io/docs/en/babel-polyfill https://github.com/facebook/create-react-app/issues/7242有用的链接: https://babeljs.io/docs/en/babel-polyfill https://github.com/facebook/create-react-app/issues/7242
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.