-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support optional chaining via acorn fork #3582
Conversation
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via
or load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## master #3582 +/- ##
=======================================
Coverage 96.35% 96.35%
=======================================
Files 180 180
Lines 6149 6149
Branches 1807 1807
=======================================
Hits 5925 5925
Misses 111 111
Partials 113 113
Continue to review full report at Codecov.
|
package.json
Outdated
@@ -146,5 +145,8 @@ | |||
"default": "./dist/rollup.js" | |||
}, | |||
"./dist/": "./dist/" | |||
}, | |||
"dependencies": { | |||
"fork-acorn-optional-chaining": "^7.2.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please no unnecessary external dependencies. Also why do we need a fork, is it impossible to do this via plugin? I do not feel good about disconnecting from core acorn updates for an unspecified time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation at https://github.com/acornjs/acorn/pull/891/files is provided as a PR not a plugin. It might be possible to convert the implementation into a plugin, I don't have the resources for that currently though unfortunately.
src/Module.ts
Outdated
@@ -116,7 +116,7 @@ export interface AstContext { | |||
} | |||
|
|||
export const defaultAcornOptions: acorn.Options = { | |||
ecmaVersion: 2020, | |||
ecmaVersion: 2021 as 2020, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought optional chaining was an ES 2020 feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was implemented as 2021 in the PR there, which I'm following - I think you are right though in that it is strictly 2020.
fd6ad48
to
f6d4333
Compare
Will this get ”in“, if by 30 June 2020 there is no estree consensus? |
It will, but there is quite a bit more to be done here. Basically we need to adjust our AST nodes and by the looks of it, create quite a few new ones to make tree-shaking work at all. This is why that is not a straight merge. |
Do you want to support an acorn fork? |
Not really, we hope this dilemma will be resolved eventually. But this seems the best way to get it in on the quick. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears my pessimism was not warranted as the merged PR reflects an early stage of the ESTree proposal where it was reusing the existing Nodes. I did not put any work to have improved tree-shaking, but treating those Nodes just as regular MemberExpressions should be a safe starting point.
192f65a
to
62224b1
Compare
62224b1
to
d479801
Compare
@lukastaegert shall we move the fork into This is not to say I'm not interested in maintaining it - would be glad to help assist with movement here. |
I fear this might send a wrong message that this fork is maintained in some way. We can wait until there is actually a reason to change something about the fork. I still hope there might be consensus on the ESTree AST and we can get rid of it again. |
Good point, we don't want to go the way of Babel's fork :) |
I upgraded to rollup
|
This suggests that it is the terser plugin complaining, not Rollup. |
I am sorry but I do not understand what you are implying, and what GUI actions have to do with anything. If you are suggesting we fix terser for you, note that this is a completely unrelated project worked on by a completely different set of people. Fixing it sounds rather unsustainable for us because resources are very limited and this is a free open source project maintained by volunteers. As is terser, by the way. So if you want this fixed, I would suggest you open an issue for that project instead, or even contribute to creating a fix there. |
My bad I had posted in the wrong thread, hence the confusion 😉 |
How can i apply this to fix the issue described here |
@ohabash its merged into master. You dont need to checkout fix branch |
@numfin Thank you for helping. This must be a terribly obvious answer given all this info but still i must ask... What do I do to fix this? |
is this install what you recommend |
I dont even understand what are you talking about. What is the connection between angular cli and rollup |
@numfin that post describe the issue i have... I prev thought it was a compiler option. But several place online now lead to rollup; specifically this fork. My app wont compile cause of the following error that occurs during an angular build.
So im looking for an action item of somekind. Like change a dependancy version or something. Im sorry but i dont know what next step should be. I think this topic is my best lead though. Thank you for being patient with me.. |
@ohabash dont be sorry, its fine. |
I turned on verbose and found a more detailed error... Do you mind taking a look? This error originates from |
@ohabash im not sure this is the best place to talk... :D do you have discord or smth? |
This was my solution ng-packagr/ng-packagr#2259 (comment) |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This uses a fork of Acorn I've published with a merged rebase of the optional chaining PR at acornjs/acorn#891.
The fork is available at https://github.com/guybedford/acorn/tree/optional-chaining and I would be glad to keep it maintained there. If you want to move it into the RollupJS org with shared publish permissions we can do that too.
The reason Acorn hasn't landed optional chaining is due to the estree block over how to implement the Node structure. RollupJS doesn't publicly expose the Node interface so I don't believe Rollup as a project should be slowed down by the lack of consensus building work being done here, if it doesn't actually affect Rollup.
There is a huge amount of userland packages and code shipping optional chaining - it's actually incredibly surprising how fast the adoption has been - I believe shipping this will be a huge practical benefit to RollupJS users!