babel / babel-preset-env

PSA: this repo has been moved into babel/babel -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-preset-env

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError when used spread (...) operator

luozhihua opened this issue · comments

ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/tree/index.vue
Module build failed: SyntaxError: Unexpected token (157:10)

  155 |       this.$emit('add', data, (node = {}) => {
  156 |         let properties = {
> 157 |           ...node
      |            ^
  158 |         }
  159 |
  160 |         store.append({children: []}, data)
  161 |       })

My .bebelrc file:

{
  "presets": [
    "react",
    [
      "env", {
        "targets": {
          "browsers": ["last 50 versions", "safari >= 7"]
        }
      }
    ]
  ],
  "plugins": [
    "babel-plugin-transform-runtime",
    "babel-plugin-add-module-exports",
    "transform-decorators-legacy",
    "transform-class-properties",
    "syntax-dynamic-import",
    "transform-vue-jsx",
    ["component", [
      {
        "libraryName": "element-ui",
        "styleLibraryName": "~src/theme/default"
      }
    ]]
  ]
}

Object rest/spread is not yet part of the specification, so it is not enabled by default.
You should either use the shippedProposals option (if you are using babel-preset-env 2) or babel-plugin-transform-object-rest-spread