mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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:
1 parent
09368db20f
commit
b73a1356ce
1 file changed
+3
-2
+3
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user