6

enter image description here

Why its not accepting spread properties ? I am using babel-preset-env for this.

.babelrc

{
    "presets": [
        "react",
        [
            "env",
            {
                "targets": {},
                "debug": true,
                "modules": "commonjs"
            }
        ]
    ]
}

package.json

{
  "name": "myapp",
  "version": "0.1.0",
  "main": "index.js",
  "private": true,
  "dependencies": {
    "babel-core": "6.25.0",
    "babel-loader": "7.1.1",
    "babel-preset-env": "^1.6.0",
    "babel-preset-react": "^6.24.1",
    "extract-text-webpack-plugin": "3.0.0",
    "file-loader": "0.11.2",
    "html-webpack-plugin": "^2.30.1",
    "moment": "^2.18.1",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router": "^4.1.2",
    "react-router-dom": "^4.1.2",
    "redux": "^3.7.2",
    "redux-form": "^7.0.3",
    "style-loader": "0.18.2",
    "url-loader": "0.5.9",
    "webpack": "3.5.1",
    "webpack-dev-server": "2.7.1",
    "webpack-node-externals": "^1.6.0"
  },
  "scripts": {
    "start": "",
    "build": "webpack"
  }
}
Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
vijay
  • 10,276
  • 11
  • 64
  • 79

1 Answers1

6

The Object rest spread operator will probably be a future feature of an ECMAScript specification (it's in stage 3 for the moment).

For now, it can be supported thanks to Babel but you have to use the transform-object-rest-spread plugin.

{
    "presets": [
        "react",
        [
            "env",
            {
                "targets": {},
                "debug": true,
                "modules": "commonjs"
            }
        ],
        "transform-object-rest-spread"
    ]
}
Erazihel
  • 7,295
  • 6
  • 30
  • 53
  • just a doub't ,i am using babel-preset-env ..this library should have imported (spread operator library) right ? – vijay Aug 21 '17 at 12:00
  • Seems like it doesn't because it's still a stage feature: https://github.com/babel/babel-preset-env/issues/49 – Erazihel Aug 21 '17 at 12:12
  • It won't be an ES7 feature because ES7 (ES2016) was already released date last year ;) – Felix Kling Aug 21 '17 at 14:21
  • ES8 has already been released as well. Also ESxxxx is the official way if referring to versions now. So, it may be ES2018 but who knows. Does it's matter? The only important part is that it is not part of the spec yet. – Felix Kling Aug 21 '17 at 14:24