当我尝试使用带有es2017的webpack运行我的应用时出现以下错误:
ERROR in ./app/app.js
Module not found: Error: Cannot resolve module 'babel-preset-es2017/polyfill' in C:\Users\mjarn\WebstormProjects\zombie-cat-production\app
@ ./app/app.js 3:0-39
我的网站设置:
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: __dirname,
query: {
presets: ['es2015', 'es2017', 'react'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties'],
}
}
]
}
我的输入文件导入语句:
import 'babel-preset-es2017/polyfill'
import React from 'react'
import ReactDOM from 'react-dom'
...
如何让它发挥作用?
答案 0 :(得分:1)
babel-preset-es2017的正确自述文件如下:https://github.com/babel/babel/tree/master/packages/babel-preset-es2017
答案 1 :(得分:0)
官方README已过期。我决定在我的stage-0
文件中添加预设.babelrc
。
{
"presets": ["es2015", "stage-0", "react"],
"env": {
"test": {
"plugins": [ "babel-plugin-rewire" ]
}
}
}
我的webpack.config
保持原样。
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: __dirname
}
]
}