doc: add module namespace object links

PR-URL: https://github.com/nodejs/node/pull/57093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Dario Piotrowicz authored and Marco Ippolito committed 2025-08-27 19:20:32 +02:00
1 parent 09368db20f
commit b73a1356ce
1 file changed
+3 -2
+3 -2
View File
@@ -205,7 +205,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.
@@ -250,7 +250,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"`.
@@ -1291,6 +1291,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