1

{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?optional[]=runtime'}

I installed babel-runtime

I use webpack with babel-loader config above, but get Object.assign is not function. How do I fix it?

Leonid Beschastny
  • 50,364
  • 10
  • 118
  • 122
Bird Eggegg
  • 449
  • 6
  • 14

2 Answers2

3

You will need to install babel-runtime.

npm install babel-runtime --save-dev

Then you can use the following as a loader in your webpack config -

{
  test: /\.js?$/,
  exclude: /node_modules/,
  loaders: ['babel?optional=runtime']
}

or

{
  test: /\.js?$/,
  exclude: /node_modules/,
  loader: 'babel-loader?optional=runtime'
}
0

It should work if you just use babel as the loader:

{ test: /\.js$/, exclude: /node_modules/, loader: 'babel'}
Oakley
  • 646
  • 10
  • 22