Browserify, Babel 6, Gulp - Unexpected token on spread operator

南笙酒味 提交于 2019-11-26 15:22:24

That syntax is an experimental proposed syntax for the future, it is not part of es2015 or react so you'll need to enable it.

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

and add

"plugins": ["transform-object-rest-spread"]

into .babelrc alongside your existing presets.

Alternatively:

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

and use stage-3 in your presets to enable all stage-3 experimental functionality.

I had the same issue, installed stage-2 plugin and modified my package.json file, which looks like below

"babel": {
    "presets": [
      "es2015",
      "react",
      "stage-2"
    ]
  }

Just as a side note, some text editors (in my case Mac Notes) will contract ... into an elepsis entity, which will fail validation, so be aware of that too...

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