This repository was archived by the owner on Jan 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Hoist await and yield #6
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You are replacing the Callxpression by an ExpressionStatement here. Would the following test code stll work, or would Babel crash or something because you are building an odd AST?
My worry is that you can't AFAIK pass a statement as the argument of a function (here, the `t.is(){ call). But I don't know how Babel would react to that. Would you mind adding a test case and see how that pans out?
I would be fine with not entirely supporting this edge case, but it should at the very least not crash.
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.
Yea I doubt that'll work… in your example
t.throws
is inside anArgumentExpression
so we'd have to walk the path back to the test implementation and detect anyArgumentExpression
nodes, then prepend the hosted statements to node's parent.But then what about:
That scenario is further complicated by this plugin running after async/await has been transpiled into a generator…
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.
So, what should we do about it? Just ignore it as an edge-case?
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 haven't had the time to get back to this. We could explore whether we can run this plugin before any other presets and plugins. Alternatively the generator compilation (for Node.js v4 and up) should reduce to
yield
expressions.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.
Relevant: babel/babel#3281
I would be ok with only supporting Node.js 4 for this.