doc: add esm and cjs examples to node:vm
#61498
Open
+408
−102
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.
This PR adds the missing
ESMandCJSexamples to their respective counterparts for the VM documentation.For the
SyntheticModuleexample I added the linking part just to showcase the new default.For the
vm.measureMemory([options])example I updated the format being shown, it used to be:And now it's:
For the example in
What does it mean to "contextify" an object?I changed the error printing so we only show the expectedTypeError: Cannot freezeinstead of the whole error stack so now instead of seeing this:We see this:
I did the same for the
vm.constants.DONT_CONTEXTIFYexamples.Also, I believe there was a typo in the code snippet for the
When microtaskMode is 'afterEvaluate', beware sharing Promises between Contexts, we where usingcontextwhen in reality it should've beeninner_context, I have fixed that. For that one I'm adding it'sCJScounterpart.I've tested all examples included in this PR and they all work/behave as expected now.
Thanks again for everything!