Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du HAMEL <duhamelantoine1995@gmail.com>2020-08-07 14:12:25 +0300
committerGeoffrey Booth <webmaster@geoffreybooth.com>2020-09-12 06:56:30 +0300
commit541d296d56db83864100756a4875496fb414d332 (patch)
tree669ebb81080c7f06d8f5047b030d919d3b6be67d /doc/api/esm.md
parentb3c6d281d7be393dc09456fbef2f677f696c42d2 (diff)
doc: document support for package.json fields
Fixes: https://github.com/nodejs/node/issues/33143 PR-URL: https://github.com/nodejs/node/pull/34970 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r--doc/api/esm.md11
1 files changed, 7 insertions, 4 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index 160a6633d7d..9a4d65d25f7 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -55,7 +55,7 @@ specifier resolution, and default behavior.
Node.js treats JavaScript code as CommonJS modules by default.
Authors can tell Node.js to treat JavaScript code as ECMAScript modules
-via the `.mjs` file extension, the `package.json` `"type"` field, or the
+via the `.mjs` file extension, the `package.json` [`"type"`][] field, or the
`--input-type` flag. See
[Modules: Packages](packages.html#packages_determining_module_system) for more
details.
@@ -253,9 +253,9 @@ can either be an URL-style relative path like `'./file.mjs'` or a package name
like `'fs'`.
Like in CommonJS, files within packages can be accessed by appending a path to
-the package name; unless the package’s `package.json` contains an `"exports"`
-field, in which case files within packages need to be accessed via the path
-defined in `"exports"`.
+the package name; unless the package’s [`package.json`][] contains an
+[`"exports"`][] field, in which case files within packages need to be accessed
+via the path defined in [`"exports"`][].
```js
import { sin, cos } from 'geometry/trigonometry-functions.mjs';
@@ -1159,3 +1159,6 @@ success!
[6.1.7 Array Index]: https://tc39.es/ecma262/#integer-index
[Top-Level Await]: https://github.com/tc39/proposal-top-level-await
[Core modules]: modules.html#modules_core_modules
+[`package.json`]: packages.html#packages_node_js_package_json_field_definitions
+[`"exports"`]: packages.html#packages_exports
+[`"type"`]: packages.html#packages_type