Skip to content

Unexpected token ... #1003

Open
Open

Description

@juvenrui

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

Activity

  1. added this to the 2.3.7 milestone on Feb 2, 2020
  2. jrburke commented on Feb 2, 2020

    @jrburke
    Member

    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.

  3. restarian commented on Feb 12, 2020

    @restarian

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

  4. jrburke commented on Feb 12, 2020

    @jrburke
    Member

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

  5. ejdaly commented on Mar 3, 2021

    @ejdaly

    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?

  6. chrswk commented on Apr 4, 2021

    @chrswk

    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?

  7. chrswk commented on Apr 10, 2021

    @chrswk

    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.

  8. ejdaly commented on May 18, 2021

    @ejdaly

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

  9. ejdaly commented on May 18, 2021

    @ejdaly

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

    jquery/esprima#2078

  10. chrswk commented on May 24, 2021

    @chrswk

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

  11. abhijithsreenivas commented on Oct 11, 2021

    @abhijithsreenivas

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

  12. theloveofcode commented on Jan 21, 2022

    @theloveofcode

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

  13. prantlf commented on Apr 23, 2023

    @prantlf

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions