webpack – 无法解析模块babel-preset-es2017 / polyfill

当我尝试使用带有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

我的webpack设置:

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'
...

我如何使其工作?

最佳答案 babel-preset-es2017的正确自述文件似乎是这样的:
https://github.com/babel/babel/tree/master/packages/babel-preset-es2017

https://github.com/babel/babel.github.io/issues/946

点赞