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

ES6 Spread syntax not work #971

Closed
pranaysonisoft opened this issue Oct 26, 2017 · 6 comments
Closed

ES6 Spread syntax not work #971

pranaysonisoft opened this issue Oct 26, 2017 · 6 comments

Comments

@pranaysonisoft
Copy link

Spread syntax allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.

`
let cold = ['autumn', 'winter'];

let warm = ['spring', 'summer'];

cold.push(...warm); `

@jrburke
Copy link
Member

jrburke commented Oct 29, 2017

The latest release of r.js (2.3.5) includes the latest esprima (4.0) to parse JS files, so I expect that parsing the file for combining into bundles work, but the uglifyjs that is in r.js is still the 2.x version, which cannot handle ES2015+ language features like spread and rest.

If that is the case here, pass optimize: none to r.js, and minify the results in your build process after calling r.js. Some discussion about this in this issue, but there are no plans to update uglifyjs used in r.js for the 2.x series since uglify 3.x has a different API and would cause issues for projects that use r.js and expect the uglify 2.x series.

There are enough ES2015+ minifier options now besides uglify, and a better way for build processes to use them compared to when r.js was released where it makes less sense now to bundle a minifier in r.js.

Closing as a discussion ticket, but feel free to continue discussion here.

@jrburke jrburke closed this as completed Oct 29, 2017
@ex1st
Copy link

ex1st commented Aug 17, 2018

Hi @jrburke

We have some trouble with parsing ES2017 code by r.js. The new minor release of esprima 4.0.1 fixed it.
Any chance to update lib? Thank you!

@jrburke
Copy link
Member

jrburke commented Aug 27, 2018

Issue #991 tracks the update for 2.3.6. Latest master snapshot is linked in that issue if you need an updated version now. Want to try to address a couple of other things before putting out 2.3.6.

@ArshSoni
Copy link

I seem to be having this same issue. I've updated my Esprima dependency to 4.0.1 as mentioned above. But it doesn't seem to have fixed the issue with requirejs and it keeps complaining about unexpected token ...

@semmel
Copy link

semmel commented Aug 28, 2021

Although valid ES6 code, Esprima v4.0.1 still can't do object spread. See Issue #2034

@timothydavis
Copy link

jquery/esprima#2034 seems to be resolved now looking at comments of jamby93 and 0x00C5

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

6 participants