-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
doc: add esm and cjs examples to node:v8
#61328
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
Open
Open
+217
−14
Conversation
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
@nodejs-github-bot
nodejs-github-bot
added
the
doc
Issues and PRs related to the documentations.
label
Jan 9, 2026
avivkeller
avivkeller
approved these changes
Jan 10, 2026
@avivkeller
avivkeller
added
the
author ready
PRs that have at least one approval, no pending requests for changes, and a CI started.
label
Jan 10, 2026
cjihrig
cjihrig
approved these changes
Jan 10, 2026
lpinca
lpinca
approved these changes
Jan 10, 2026
himself65
himself65
approved these changes
Jan 11, 2026
UlisesGascon
UlisesGascon
approved these changes
Jan 12, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 V8 documentation.For the
setFlagsFromStringexample, we weren't printing anything back to the user so the example looked like we just hang the terminal for one minute and then come back. So I added some events (the ones usingnew Array()) to add some computation that would trigger the GC so we can get some output for the example, then it showcases the actual behavior by invokingsetFlagsFromString('--notrace-gc')that stops the tracing, users can see we're still creating Arrays for one more second but the GC events are now stopped viasetFlagsFromString().The same was happening for the
Promise hooksexample (in this case I added itsCJScounterpart). We were not giving any output back to the users, so it may not be clear what it's going on, I just added the invocation of one Promise (promisePrint) so now we can see all theconsole.logfrom the Promise life cycle.The same was also happening for the
isStringOneByteRepresentationexample so i just added a couple ofconsole.logto print thebufferand see its contents.Now all these examples give some output to users trying to understand this parts of the documentation.
There was one particular example that I couldn't make work using
ESM, it's theStartup Snapshot APIexample, it works fine usingCJSbut when usingESMit throws an error, sadly I lack the V8 knowledge right now to make it work, I tested it on versionsv18.20.8,v20.19.6,v22.21.1,v24.12.0andv25.1.0For version
v18.20.8the error is:And from version
v20.19.6onwards the error is:I made a simple POC to reproduce the error easily here, I already asked for help in the discord but we couldn't make it work, maybe someone with better V8 expertise can help with this one.
That's it for now! Thank you and happy new year! 💚 🥳