-
Notifications
You must be signed in to change notification settings - Fork 883
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
Can't parse spread operator #388
Comments
Spread in object literals is not part of any ECMA standard that Acorn can parse. Hence the error. |
Holy cow, I thought it was in the standard, but you're totally right. Would you suggest using |
Yep, works great once I enable the |
Not sure what you are asking. Acorn supports all ES2015/ES6 features. Babylon is integrated in Babel and therefore Babel's plugins (which support nonstandard, non-ES6 plugins like babel-plugin-transform-object-rest-spread). Acorn has its own plugin system. |
Poor choice of words. |
@dmatteo As an option, you can write plugin for Acorn to support that. |
@RReverser @dmatteo @TimothyGu here it is https://github.com/UXtemple/acorn-object-spread :). I basically brought it in from babylon. I also pushed a PR to buble https://gitlab.com/Rich-Harris/buble/merge_requests/44 to support it, hopefully it makes it in :). |
@dariocravero Awesome, great work! |
Just a heads up, the object-rest-spread is now supported natively in Chrome 60 and Node 8.3.0 out of the box. It may be worth adding since v8 has it implemented unflagged already. Related to standard-things/esm#14 |
@jdalton It is still stage 3 though, and Acorn accepts only stage 4 features for easier maintainance. Moreover, the latest parsing-related change in the proposal has been committed only 3 days ago: tc39/proposal-object-rest-spread@72deb7d |
Maybe an exception to the rule is called for since implementations are shipping this unflagged. |
Aren't they always doing this in stage 3? (as far as I remember, it's exactly for implementation feedback) |
It's my understanding that implementations for feedback are usually flagged. |
Would love to see this fix land. |
Again, I don't want to do extra work and complicate our backwards-compatibility story by tracking unstable proposals, and it would be great if you all could just get used to the 'use a plugin until it reaches stage 4' reality. Drive-by comments like "Would love to see this fix land" we can also really do without. |
@marijnh The reality is that support for object rest-spread is in stable versions of Chrome and Node and that the existing plugin isn't to the bar it really should be (i.e. it has 1 commit). I understand not wanting to take on the compatibility burden, but seeing as the work put in will not likely be wasted (as it's not a question of if the feature is landing wider, but when) it would be rad if there could be an official plugin (made by Acorn core). That way folks could leverage a quality plugin and you all could get the jump on implementing the syntax while not taking on the compat burden for the primary project. If Acorn is up for going the official plugin route, I can help. |
@marijnh As a maintainer it's cool to know when users really want a feature or a fix (also, there are no reactions on the mobile version of GH, so I would have used that otherwise) |
You can just use babylon until it's supported in acorn at Stage 4, the tools have difference use cases/times to implement. |
So improve it or write a better one. |
Seeing if Chrome team would be up for creating or updating a plugin |
@jdalton Small nit: looks like they used Acorn for ~2 years now https://github.com/auchenberg/chrome-devtools-app/tree/master/app/devtools/front_end/acorn, and now just widened its usage. |
Updates: Node is now using Acorn to parse top-level Chromium wants to pull its Acorn use in DevTools: |
Could one re-consider that? It is widely-adopted as of November 2017. Many environments support it -- Firefox, Chrome, NodeJS. Other tools as well -- babel, uglifyjs, etc. Also, support in acorn blocks introducing this support in webpack that is somehow a show stopper. Without it you cannot pack JS code and deliver to the client. |
Don't stop the show. Use https://github.com/victor-homyakov/acorn-object-rest-spread |
By the way, it is Stage 3 proposal now https://github.com/tc39/proposals/blob/master/README.md Stage 3 means "Candidate", i.e. close to be accepted. |
Stage 3 is a pretty common place to be in and they are planning to get accepted in the next months. No need to rush anything. |
It's not a show stopper for webpack (use the appropriate Babel plugin).
The one by Acorn's own, or should really soon to be own, @adrianheine is more accurate
It would be nice if Acorn core could read the temperature a bit better, but I get it. Acorn is the best option in parsers at the moment, even with lack of support for common things like object-rest-spread. I make due hacking together plugins until features meet their bar. By the way, for folks just wanting parse support without concern for syntax validation, object-rest-spread is pretty straight forward. |
This will probably get merged pretty soon, see #658. |
#658 was merged. |
Hi Marijn,
I'm using
acorn 3.0.2
with the pluginacorn-jsx 2.0.1
, butacorn
is throwing on the spread operator when used inside an object:Weirdly enough, this is totally fine
Being part of ES6, the spread operator should be completely supported, right?
Can you spot something I'm doing wrong?
p.s. I'm not overriding
options.ecmaScript
, defaulting to 6The text was updated successfully, but these errors were encountered: