Use babel-loader, but Object.assign is not a function

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

I installed babel-runtime

I use webpack with babel-loader configuration above, but get Object.assign does not work. How to fix it?

+1
webpack babeljs
Aug 20 '15 at 16:02
source share
2 answers

You will need to install babel-runtime.

 npm install babel-runtime --save-dev 

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

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

or

 { test: /\.js?$/, exclude: /node_modules/, loader: 'babel-loader?optional=runtime' } 
+3
Aug 20 '15 at 23:44
source share

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

 { test: /\.js$/, exclude: /node_modules/, loader: 'babel'} 
0
Aug 20 '15 at 17:41
source share



All Articles