Thursday, 8 June 2017

Why babel preset "env" does not transpile destructuring statements?

In my code there is following statement:

const { a, b } = something;

My .babelrc

{
  "presets": [
    ["env", {
      "targets": { "node": "current" }
    }]
  ]
}

My node version: 4.6.1.
babel-cli: 6.24.1
babel-preset-env: 1.5.2

After transpiling code, when I run it I get "Syntax error: unexpected token {":

const { a, b } = something
      ^

I seems that it does not transpile "destructuring code"... I tried to add but it did not change anything:

"plugins": [
  "transform-es2015-destructuring"
]

Any idea what might be wrong?



via user606521

No comments:

Post a Comment