diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2022-01-17 13:36:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-17 13:36:19 +0300 |
commit | 87325917ec2e57c8b70eba78695dbeaa1ac181a5 (patch) | |
tree | dad2200786e1e2cd35d475f009938806ca511097 /doc/api/esm.md | |
parent | 0594577e69b11dccfa1d45453a712450a0cefbe0 (diff) |
doc: clarify module system selection
Refs: https://github.com/nodejs/node/pull/41345#discussion_r777115823
PR-URL: https://github.com/nodejs/node/pull/41383
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r-- | doc/api/esm.md | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md index 54f576261c2..3b74ff03bc6 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -94,12 +94,12 @@ provides interoperability between them and its original module format, <!-- type=misc --> -Node.js treats JavaScript code as CommonJS modules by default. -Authors can tell Node.js to treat JavaScript code as ECMAScript modules +Node.js has two module systems: [CommonJS][] modules and ECMAScript modules. + +Authors can tell Node.js to use the ECMAScript modules loader via the `.mjs` file extension, the `package.json` [`"type"`][] field, or the -`--input-type` flag. See -[Modules: Packages](packages.md#determining-module-system) for more -details. +[`--input-type`][] flag. Outside of those cases, Node.js will use the CommonJS +module loader. See [Determining module system][] for more details. <!-- Anchors to make sure old links find a target --> @@ -1443,6 +1443,7 @@ success! [CommonJS]: modules.md [Conditional exports]: packages.md#conditional-exports [Core modules]: modules.md#core-modules +[Determining module system]: packages.md#determining-module-system [Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports [ES Module Integration Proposal for WebAssembly]: https://github.com/webassembly/esm-integration [Import Assertions]: #import-assertions @@ -1454,6 +1455,7 @@ success! [WHATWG JSON modules specification]: https://html.spec.whatwg.org/#creating-a-json-module-script [`"exports"`]: packages.md#exports [`"type"`]: packages.md#type +[`--input-type`]: cli.md#--input-typetype [`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer [`SharedArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer [`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |