React Polyfill ReplaceAll
最近使用Create React App创建一个APP,使用react-app-polyfill/stable
完成Polyfill,但是,发现string.replaceAll()函数一直没有polyfill。打开core-js/stable/index.js,发现已经包含了require('../modules/es.string.replace-all')。第一次遇到这种情况,相对懵逼。
经过一番的查阅,最后在babel官网看到一条消息(https://babeljs.io/docs/en/babel-preset-env#corejs):
By default, only polyfills for stable ECMAScript features are injected: if you want to polyfill proposals, you have three different options:
* when using useBuiltIns: "entry", you can directly import a proposal polyfill: import "core-js/proposals/string-replace-all".
继续阅读→