Skip to content

doc: fix synchronous module hook examples - #66378

Open
hanityx wants to merge 1 commit into
nodejs:mainfrom
hanityx:docs-module-hook-examples
Open

hanityx wants to merge 1 commit into
nodejs:mainfrom
hanityx:docs-module-hook-examples

Conversation

@hanityx

@hanityx hanityx commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

In the synchronous load() example, ...result overwrites the
foo-to-bar replacement. Spread result first and use TextDecoder for
non-string text sources, leaving nullish sources and WebAssembly
unchanged. Also match the file URL returned by the preceding
resolve() example rather than the original special-module specifier.

The synchronous import-map example calls readFileSync(), which is
provided by node:fs, not node:fs/promises.

Use node:fs for readFileSync in the synchronous import-map example.

Preserve transformed source in the synchronous load example, skip null
and WebAssembly sources, and decode byte sources with TextDecoder.
Match the special-case URL returned by the preceding resolve example.

Assisted-by: opencode
Signed-off-by: hanityx <hanityx@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. module Issues and PRs related to the module subsystem. labels Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to Node.js documentation. module Issues and PRs related to the module subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants