Open olalonde opened 8 years ago
Think I got it to work with:
{
"presets": ["es2015-node6"],
"plugins": [
"babel-plugin-transform-es2015-destructuring",
"transform-object-rest-spread"
]
}
You're right, I'll add back transform-es2015-destructuring
, until this issue is resolved.
Keep this issue open. :)
Node.js@6 has destructing support! http://node.green
@ss4xxi it does... The issue is that transform-object-rest-spread
doesn't work without transform-es2015-destructuring
for some reason.
This playground can simply reproduce the problem. Also I commented on T7316.
I'll try to fix it this week.
@jhen0409 thanks :)
Object rest spread depends on destructuring so we would have to rewrite it to be independent of it
What's preventing this issue from being closed?
Probably because Babel still requires additional plugins for object rest spread to work (https://github.com/babel/babel/issues/4074), babel-plugin-transform-es2015-destructuring
and babel-plugin-transform-es2015-parameters
which are otherwise not required for Node v6.
After many hours searching for info and lots of trial and error, I have tried every combination of plugins and presets possible, yet none of them have worked. Can someone please confirm a set up that works? I am compiling for the browser and am running webpack in Node V6.2.2
@Billy- Use es2015
for browser bundle and es2015-node6/object-rest
for node.
As I said, I have tried every combination of plugins and presets I have come across. My most recent babelrc file contains es2015 preset (and react), transform-es2015-destructuring and transform-object-rest-spread plugins.
Can you share your .babelrc file and what parsing error you are getting? I'm using:
{
"presets": ["eslatest-node6"],
"plugins": [
"transform-es2015-destructuring",
"transform-es2015-parameters",
["transform-object-rest-spread", { "useBuiltIns": true }]
]
}
Sorry guys, false alarm.. Not sure what was going on at work earlier. Pulled down my WIP and it worked :angry:. I reduced down my .babelrc and it actually works with only the object rest spread transform plugin:
{
"presets": [
"es2015",
"react"
],
"plugins": [
"transform-object-rest-spread"
]
}
Will try to replicate the issue at work on Monday...
trying to get it working for node..
"babel-plugin-transform-es2015-destructuring": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-0": "^6.16.0",
"babel-register": "^6.18.0",
{
"presets": ["es2015", "stage-0"],
"plugins": ["transform-es2015-destructuring", "transform-object-rest-spread"]
}
and it still complains Syntax Error
https://github.com/babel/babel/releases/tag/v6.19.0 "Make the plugin work standalone with parameters/destructuring plugins"
Yep it should work now without the 2 plugins!
@hzoo can you confirm this is actually working? I'm using "presets": ["es2015-node6", "stage-0"]
but still get SyntaxError: Unexpected token ...
. It's working as expected with es2015-node6/object-rest. I've confirmed that babel-plugin-transform-object-rest-spread@6.19.0 is installed.
@deadbeef84 can be related: https://github.com/babel/babel/pull/4883
can you confirm this is actually working
You can test in the repl - it would be useful you can post the relevant code too. The transform basically had to be rewritten for rest so it's likely some cases were missed.
I love babel, and thanks for the work on it!
I'm coming across a similar error. I was following https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters#Destructuring_rest_parameters, and in Babel, I'm unable to get either of the following to work (SyntaxError is the result):
function foo(a, b, ...[ c, d ]) { }
function foo(...[ c, d ]) { }
I don't know if those are intended to work with the solo object rest spread plugin. I'm running babel-plugin-transform-object-rest-spread@6.20.2.
@juanpaco I think it's this bug: https://github.com/babel/babel/issues/4851 .. work around is to "use the parameter/destructuring transforms until it's fixed".
Since Babel 6.22 transform-object-rest-spread
works fine finally, there is no need to use es2015-node6/object-rest
preset anymore, just es2015-node6
is quite enough.
I think this issue and #4 can be closed
Anyone managed to get this preset to work with https://babeljs.io/docs/plugins/transform-object-rest-spread/?
Seems it works fine for spread but doesn't work for rest. I'm guessing I need to install an additional preset. Reported here as well: https://phabricator.babeljs.io/T7316