更新到 babel 7 beta 后,看起来 babel polyfill 在 bundle 之前没有转译。我更新了所有范围包,例如“@babel/polyfill”:“7.0.0-beta.36”。并将两个文件的导入从 import 'babel-polyfill' 更改为 import '@babel/polyfill'。如何在 babel env 和 babel 中使用 babel/polyfill 7. 在使用 useBuiltIns: 'usage' 时,我应该使用 babel/polyfill 吗?
.babelrc.js
const nodeEnv = process.env.NODE_ENV || 'development'
let presetEnvConfig, plugins
if (nodeEnv === 'test'){
presetEnvConfig = {targets: {node: 'current'}}
plugins = ['istanbul']
} else {
presetEnvConfig = {
targets: {
browsers: ['last 2 versions', 'ie >= 11']
},
modules: false
}
plugins = ['react-hot-loader/babel']
}
const config = {
presets: [
['@babel/preset-env', presetEnvConfig],
'@babel/react',
'@babel/stage-2'
],
plugins,
}
类型.js
import keyMirror from '../../../utils/keyMirror'
export default keyMirror({
Unassign: null,
Reassign: null,
QuickAssignment: null,
}, 'TagAssignmentTypes')
index.js
<Assignment
assignee={assignee}
tagId={tagId && tagId.toString(16)}
assignmentType={assignmentTypes.Reassign}
onRequestClose={() => this.setState({isAssignmentInProgress: false})}
onChange={onChange}
/>