-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
vm: expose hasTopLevelAwait on SourceTextModule #59865
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
base: main
Are you sure you want to change the base?
Conversation
Expose `hasTopLevelAwait` and `getHasAsyncGraph` on `vm.SourceTextModule`. `getHasAsyncGraph` requires the module to be instantiated first.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59865 +/- ##
==========================================
+ Coverage 87.76% 88.27% +0.51%
==========================================
Files 702 702
Lines 206690 206703 +13
Branches 39679 39775 +96
==========================================
+ Hits 181392 182467 +1075
+ Misses 17252 16258 -994
+ Partials 8046 7978 -68
🚀 New features to boost your workflow:
|
@@ -920,6 +920,33 @@ to disallow any changes to it. | |||
Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record][]s in | |||
the ECMAScript specification. | |||
|
|||
### `sourceTextModule.getHasAsyncGraph()` |
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.
Does it need to be a method? It seems fine to just make it a getter property, and it would be more consistent with other getter properties (e.g. error
requires the module to be errored, but it's still a getter property)
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.
This requires the module to be instantiated, and throws before instantiation.
I think throwing in a getter is not a good pattern. Making it a method indicates that this could incur traversal on the dependency graph, and may throw if this is not instantiated.
Returns `true` if the module has a dependency graph that contains top-level | ||
`await` expressions, otherwise returns `false`. |
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.
Returns `true` if the module has a dependency graph that contains top-level | |
`await` expressions, otherwise returns `false`. | |
Iterates over the dependency graph and returns `true` if any module in its dependencies or | |
this module itself contains top-level `await` expressions, otherwise returns `false`. | |
The search may be slow if the graph is big enough. |
Expose
hasTopLevelAwait
andgetHasAsyncGraph
onvm.SourceTextModule
.getHasAsyncGraph
requires the module to be instantiated first.Fixes: #59656