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

Unexpected token ... #16

Closed
klimashkin opened this issue Jun 18, 2018 · 8 comments
Closed

Unexpected token ... #16

klimashkin opened this issue Jun 18, 2018 · 8 comments
Labels

Comments

@klimashkin
Copy link

Seems it fails on javascript files that use object rest/spread.

[23:46:18] Error: Line 1: Unexpected token ...
  at ErrorHandler.constructError (/node_modules/recast/node_modules/esprima/dist/esprima.js:5004:22)
  at ErrorHandler.createError (/node_modules/recast/node_modules/esprima/dist/esprima.js:5020:27)
  at JSXParser.Parser.unexpectedTokenError (/node_modules/recast/node_modules/esprima/dist/esprima.js:1985:39)
  at JSXParser.Parser.throwUnexpectedToken (/node_modules/recast/node_modules/esprima/dist/esprima.js:1995:21)
  at JSXParser.Parser.parseObjectPropertyKey (/node_modules/recast/node_modules/esprima/dist/esprima.js:2492:33)
  at JSXParser.Parser.parseObjectProperty (/node_modules/recast/node_modules/esprima/dist/esprima.js:2527:25)
  at JSXParser.Parser.parseObjectInitializer (/node_modules/recast/node_modules/esprima/dist/esprima.js:2595:35)
  at JSXParser.Parser.inheritCoverGrammar (/node_modules/recast/node_modules/esprima/dist/esprima.js:2278:37)
  at JSXParser.Parser.parsePrimaryExpression (/node_modules/recast/node_modules/esprima/dist/esprima.js:2347:38)
  at JSXParser.parsePrimaryExpression (/node_modules/recast/node_modules/esprima/dist/esprima.js:466:97)

Espree can be updated to version 4, or to fix that in espree 3, option experimentalObjectRestSpread: true can be passed

@klimashkin
Copy link
Author

klimashkin commented Jun 18, 2018

In general it would be great to have a way to pass options from processJs to espree directly (add some espreeOptions param), because sometimes we want to stop transpiling some ES20XX features without waiting for a whole ES20XX spec to be finalized, as browsers start supporting it

@JPeer264
Copy link
Owner

@klimashkin thanks for your issue. Oh yes passing the options to espree directly would be great indeed. I will work on that as soon as I have time 👍

@JPeer264 JPeer264 added the bug label Jun 18, 2018
@klimashkin
Copy link
Author

Probably as a fast fix you could release minor update of node-rcs-core that will require espree as ^4.0.0-rc.0 || ^4.0.0.
Spec will not be changing and seems like they just wait it to be published to bump final 4.0.0

@JPeer264
Copy link
Owner

The problem is, I just checked, I am not using espree (it was accidentally in the dependencies). I use recast which is using esprima under the hood. I now have to think about the solution right now, as I can switch the parsers from recast. I hope I will find a general solution

@klimashkin
Copy link
Author

Oh, my bad, I was sure I saw espree in the source.
I think problem with esprima is that it's jquery project that is not really maintained anymore.
espree is better because it uses acorn, which is being developed pretty good.

@JPeer264
Copy link
Owner

Yap, I thought about the same. I think espree is the way to go.

@JPeer264
Copy link
Owner

With v2.0.0 it should be fixed, and your options are now added. For that, please check out the parserOptions.

@klimashkin
Copy link
Author

klimashkin commented Jun 19, 2018

Awesome, it works! Thank you!

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

2 participants