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 ... #1003

Open
juvenrui opened this issue Jan 31, 2020 · 12 comments
Open

Unexpected token ... #1003

juvenrui opened this issue Jan 31, 2020 · 12 comments
Milestone

Comments

@juvenrui
Copy link

juvenrui commented Jan 31, 2020

// blabla.js
const a = {a: 1, b: 2};
const b = {...a, c: 3};

node r.js -o blabla.js

output error: Error: Line 2: Unexpected token ...

@jrburke jrburke added this to the 2.3.7 milestone Feb 2, 2020
@jrburke
Copy link
Member

jrburke commented Feb 2, 2020

This looks to be an issue with Esprima: last release for it was 4.0.1 (2 years ago), and it seems like it is not keeping up with the new standards: jquery/esprima#1949

In that Esprima issue, another project switched away from Esprima to espree. I just tried dropping in espree into r.js, but some of the r.js tests fail (4 failing tests), so it is not a drop in replacement. I don't have time to look more into it now. So for now the workaround is to avoid object spread in the source code.

@restarian
Copy link

As a follow up, is there an easy way to pass in espima options with the config or cli? Maybe a {tolerant: true} option.

@jrburke
Copy link
Member

jrburke commented Feb 12, 2020

Looking back in the code, there currently is not a way to provide options to pass to Esprima.

@ejdaly
Copy link

ejdaly commented Mar 3, 2021

Looking at Esprima, it seems that the master branch is being updated fairly regularly (but no releases, as you mentioned).

I've tried pulling in a build from the master branch (along with a couple pending PRs related to ES2019 syntaxes), and adding to build/jslib/esprima.js

This seems to work fine (one test fails, but it also fails with the current r.js... It seems to be an outdated test file..?).

This would add support for:

  • Optional chaining
  • Optional catch
  • Nullish coalescing
  • for await...of (async iterators)

If you like, I can open a PR for this change?

@chrswk
Copy link

chrswk commented Apr 4, 2021

I would love to see an update to the latest Esprima master. Is there something I can help with directly, or something I can "encourage" through a bounty?

@chrswk
Copy link

chrswk commented Apr 10, 2021

Looking at Esprima, it seems that the master branch is being updated fairly regularly (but no releases, as you mentioned).

I've tried pulling in a build from the master branch (along with a couple pending PRs related to ES2019 syntaxes), and adding to build/jslib/esprima.js

This seems to work fine (one test fails, but it also fails with the current r.js... It seems to be an outdated test file..?).

This would add support for:

  • Optional chaining
  • Optional catch
  • Nullish coalescing
  • for await...of (async iterators)

If you like, I can open a PR for this change?

Do you mind creating a PR with all your changes? I only got started with fixing the test case, but you have already done the work integrating Esprima master.

@ejdaly
Copy link

ejdaly commented May 18, 2021

@chrswk - apologies, I hadn't seen the reply. I'll take a look at opening a PR here when I get a chance.

I did the upgrade of Esprima-to-master in my fork if you want to check that out: https://github.com/ejdaly/r.js

(I seem to have made 2 small commits after that, so you may / may not want those commits...)

@ejdaly
Copy link

ejdaly commented May 18, 2021

Aside: there may be some momentum starting to get a new Esprima release, which would be fantastic...

jquery/esprima#2078

@chrswk
Copy link

chrswk commented May 24, 2021

@ejdaly No worries. I've been using your version/fork for a couple of weeks now, so thanks again for your efforts!

@abhijithsreenivas
Copy link

Still optional chaining is failing r.js, web-packing. When this will get resolved?

@theloveofcode
Copy link

This causes problems with a lot of new JS functionality like optional chaining, spread, etc. I recommend requirejs upgrade to espira-next

@prantlf
Copy link

prantlf commented Apr 23, 2023

The parser bundled to r.js is too old. You'll need to upgrade it. See #998.

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

No branches or pull requests

8 participants