ReactJS: webpack: Failed to compile with spread syntax

此生再无相见时 提交于 2019-11-28 14:31:54

In order to use spread syntax, you need to configure you babel loader, You have a couple of option

First: Use plugin "transform-object-rest-spread"

Install it using

npm install --save-dev babel-plugin-transform-object-rest-spread

and use it

   options: {
       cacheDirectory: true,
       presets: ['react', 'env']
       plugins: ['transform-object-rest-spread']
   }

Second: use stage-0 preset, Install it using

npm install --save-dev babel-preset-stage-0

and use it like

options: {
   cacheDirectory: true,
   presets: ['react', 'env', 'stage-0']
}

Check this babel-documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!