I have the following object:
const action = {id: 100, name: 'Andres', age: 27, type: 'CREATE_USER'}
I want to copy some properties into another object. In latest version of Chrome I can do:
const newUser = {id, name, age} = action;
And the newUser
object contains:
{id: 100, name: 'Andres', age: 27}
This works fine in the browser. However, with my compiled JS code it doesn't work. I get:
error ReferenceError: id is not defined
If I remove id
, I get the same message with different key and so on.
My setup:
"webpack": "2.1.0-beta.21"
"webpack-dev-server": "2.1.0-beta.0"
And for Babel:
"babel-core": "6.x",
"babel-eslint": "6.x",
"babel-loader": "6.x",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "6.x",
"babel-polyfill": "^6.8.0",
"babel-preset-es2015": "6.x",
"babel-preset-es2015-native-modules": "^6.6.0",
"babel-preset-react": "6.x",
"babel-preset-stage-0": "6.x",
Is there something I'm missing with Babel or Webpack to accomplish what I want?