ReactJS: webpack: Failed to compile with spread syntax

后端 未结 1 443
无人共我
无人共我 2020-12-12 05:14

I want to show you my problem.

My env:

Node: 8.9.1
npm: 5.6.0
yarn: 1.3.2

package.json

  \"devDependencies\": {
           


        
1条回答
  •  隐瞒了意图╮
    2020-12-12 05:44

    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

    0 讨论(0)
提交回复
热议问题