Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with transform-object-rest-spread #2

Open
olalonde opened this issue Apr 26, 2016 · 25 comments
Open

Doesn't work with transform-object-rest-spread #2

olalonde opened this issue Apr 26, 2016 · 25 comments
Labels

Comments

@olalonde
Copy link

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

@olalonde
Copy link
Author

Think I got it to work with:

{
  "presets": ["es2015-node6"],
  "plugins": [
    "babel-plugin-transform-es2015-destructuring",
    "transform-object-rest-spread"
  ]
}

@jhen0409
Copy link
Owner

You're right, I'll add back transform-es2015-destructuring, until this issue is resolved.

Keep this issue open. :)

@ssova-4xxi
Copy link

Node.js@6 has destructing support!
http://node.green

@olalonde
Copy link
Author

@ss4xxi it does... The issue is that transform-object-rest-spread doesn't work without transform-es2015-destructuring for some reason.

@jhen0409
Copy link
Owner

jhen0409 commented May 3, 2016

This playground can simply reproduce the problem. Also I commented on T7316.

I'll try to fix it this week.

@olalonde
Copy link
Author

olalonde commented May 4, 2016

@jhen0409 thanks :)

@jhen0409
Copy link
Owner

jhen0409 commented May 4, 2016

Now T7316 is merged to T7086.

It looks transform-es2015-parameters is also required, maybe we can split to new file, use es2015-node6/object-rest as a short-term solution?

UPDATED I splitted destructuring, parameters to es2015-node6/object-rest on v0.2.0, or you can still use v0.1.

@hzoo
Copy link

hzoo commented May 5, 2016

Object rest spread depends on destructuring so we would have to rewrite it to be independent of it

@antitoxic
Copy link

What's preventing this issue from being closed?

@olalonde
Copy link
Author

Probably because Babel still requires additional plugins for object rest spread to work (babel/babel#4074), babel-plugin-transform-es2015-destructuring and babel-plugin-transform-es2015-parameters which are otherwise not required for Node v6.

@Billy-
Copy link

Billy- commented Oct 28, 2016

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

@antitoxic
Copy link

@Billy- Use es2015 for browser bundle and es2015-node6/object-rest for node.

@Billy-
Copy link

Billy- commented Oct 28, 2016

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.

@olalonde
Copy link
Author

olalonde commented Oct 28, 2016

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 }]
  ]
}

@Billy-
Copy link

Billy- commented Oct 28, 2016

Sorry guys, false alarm.. Not sure what was going on at work earlier. Pulled down my WIP and it worked 😠. 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...

@ahmed1490
Copy link

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

@klimashkin
Copy link

https://github.com/babel/babel/releases/tag/v6.19.0
"Make the plugin work standalone with parameters/destructuring plugins"

@hzoo
Copy link

hzoo commented Nov 16, 2016

Yep it should work now without the 2 plugins!

@deadbeef84
Copy link

@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.

@christophehurpeau
Copy link

@deadbeef84 can be related: babel/babel#4883

@hzoo
Copy link

hzoo commented Nov 22, 2016

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.

@juanpaco
Copy link

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.

@olalonde
Copy link
Author

@juanpaco I think it's this bug: babel/babel#4851 .. work around is to "use the parameter/destructuring transforms until it's fixed".

@klimashkin
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests