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

Error with spread operator #281

Closed
cetra3 opened this Issue Nov 10, 2015 · 8 comments

Comments

Projects
None yet
5 participants
@cetra3
Copy link

cetra3 commented Nov 10, 2015

Trying to rollup redux I get this error:

Error parsing /Users/cetra/git/redux/src/utils/applyMiddleware.js: Unexpected token (33:6) in /Users/cetra/git/redux/src/utils/applyMiddleware.js

Line 33 is part of the return statement which reads:

    return {
      ...store,
      dispatch
    }

Appears to be an error parsing the spread operator on return statements.

@Victorystick

This comment has been minimized.

Copy link
Member

Victorystick commented Nov 10, 2015

Rollup uses Acorn for parsing. Since the object-spread operator is currently in ES Stage 2, I'm not sure whether Acorn implements it or not. If not, that would explain the parse error.

I know that Acorn doesn't handle the Stage 1 export extensions we're looking forward to (#82). I believe it must be in the official spec for it to be implemented.

@Rich-Harris

This comment has been minimized.

Copy link
Contributor

Rich-Harris commented Nov 10, 2015

There's actually an open PR on the Redux repo that replaces the current build process with Rollup: https://github.com/rackt/redux/pull/964 You could take a look at that to see how it's done. Essentially, you need to transpile the source code to ES5 (which you'd need to do anyway, for it to run anywhere), which means using rollup-plugin-babel.

I'll close this issue but feel free to ask any follow-up questions you have

@cetra3

This comment has been minimized.

Copy link

cetra3 commented Nov 10, 2015

@Victorystick strange that it doesn't error out on the spread operator on the function, just on the return value. I've also checked out the source for rollup and there does seem to be rudimentary support for the spread operator.

The spread operator is a part of ES6 standard, not ES7:
http://www.ecma-international.org/ecma-262/6.0/#sec-array-initializer

@Rich-Harris

This comment has been minimized.

Copy link
Contributor

Rich-Harris commented Nov 10, 2015

The spread operator for arrays is part of ES6. For objects the semantics are slightly different – it's a separate proposal that hasn't made it into a spec yet, and thus isn't supported by Acorn

@cetra3

This comment has been minimized.

Copy link

cetra3 commented Nov 11, 2015

Ok, my apologies. Thanks for the clarification.

@salztorte

This comment has been minimized.

Copy link

salztorte commented Feb 5, 2016

Is there a solution for this Problem?

I try to use React and Redux and nothing goes.

@TrySound

This comment has been minimized.

Copy link
Member

TrySound commented Feb 5, 2016

@salztorte Just process redux with babel and include babel-plugin-transform-object-rest-spread in babel plugin list.

@salztorte

This comment has been minimized.

Copy link

salztorte commented Feb 5, 2016

thx for the quick answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment