Skip to content

Commit

Permalink
doc: add module namespace object links
Browse files Browse the repository at this point in the history
PR-URL: #57093
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
dario-piotrowicz authored and targos committed Feb 25, 2025
1 parent 21d795a commit 0de128c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ regarding which files are parsed as ECMAScript modules.
`"type": "commonjs"`, and the module contains ES module syntax.

If the ES Module being loaded meets the requirements, `require()` can load it and
return the module namespace object. In this case it is similar to dynamic
return the [module namespace object][]. In this case it is similar to dynamic
`import()` but is run synchronously and returns the name space object
directly.

Expand Down Expand Up @@ -249,7 +249,7 @@ by tools converting ES modules into CommonJS modules, following existing ecosyst
conventions. Code authored directly in CommonJS should avoid depending on it.

When an ES Module contains both named exports and a default export, the result returned by `require()`
is the module namespace object, which places the default export in the `.default` property, similar to
is the [module namespace object][], which places the default export in the `.default` property, similar to
the results returned by `import()`.
To customize what should be returned by `require(esm)` directly, the ES Module can export the
desired value using the string name `"module.exports"`.
Expand Down Expand Up @@ -1296,6 +1296,7 @@ This section was moved to
[`process.features.require_module`]: process.md#processfeaturesrequire_module
[`require.main`]: #requiremain
[exports shortcut]: #exports-shortcut
[module namespace object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object
[module resolution]: #all-together
[native addons]: addons.md
[subpath exports]: packages.md#subpath-exports
Expand Down

0 comments on commit 0de128c

Please sign in to comment.