summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/api/cli.md8
-rw-r--r--doc/api/esm.md19
-rw-r--r--doc/node.13
3 files changed, 27 insertions, 3 deletions
diff --git a/doc/api/cli.md b/doc/api/cli.md
index e0c2573882..df7a6362ac 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -165,6 +165,13 @@ added: v12.7.0
Enable experimental resolution using the `exports` field in `package.json`.
+### `--experimental-json-modules`
+<!-- YAML
+added: v12.9.0
+-->
+
+Enable experimental JSON support for the ES Module loader.
+
### `--experimental-modules`
<!-- YAML
added: v8.5.0
@@ -992,6 +999,7 @@ Node.js options that are allowed are:
* `--enable-source-maps`
* `--es-module-specifier-resolution`
* `--experimental-exports`
+* `--experimental-json-modules`
* `--experimental-loader`
* `--experimental-modules`
* `--experimental-policy`
diff --git a/doc/api/esm.md b/doc/api/esm.md
index e0a548f042..951ce41819 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -587,11 +587,16 @@ syncBuiltinESMExports();
fs.readFileSync === readFileSync;
```
-## JSON Modules
+## Experimental JSON Modules
-JSON modules follow the [WHATWG JSON modules specification][].
+Currently importing JSON modules are only supported in the `commonjs` mode
+and are loaded using the CJS loader. [WHATWG JSON modules specification][] are
+still being standardized, and are experimentally supported by including the
+additional flag `--experimental-json-modules` when running Node.js.
-The imported JSON only exposes a `default`. There is no
+When the `--experimental-json-modules` flag is included both the
+`commonjs` and `module` mode will use the new experimental JSON
+loader. The imported JSON only exposes a `default`, there is no
support for named exports. A cache entry is created in the CommonJS
cache, to avoid duplication. The same object will be returned in
CommonJS if the JSON module has already been imported from the
@@ -604,6 +609,14 @@ Assuming an `index.mjs` with
import packageConfig from './package.json';
```
+The `--experimental-json-modules` flag is needed for the module
+to work.
+
+```bash
+node --experimental-modules index.mjs # fails
+node --experimental-modules --experimental-json-modules index.mjs # works
+```
+
## Experimental Wasm Modules
Importing Web Assembly modules is supported under the
diff --git a/doc/node.1 b/doc/node.1
index 2b7e3dc429..7f786a05c6 100644
--- a/doc/node.1
+++ b/doc/node.1
@@ -108,6 +108,9 @@ Requires Node.js to be built with
.It Fl -es-module-specifier-resolution
Select extension resolution algorithm for ES Modules; either 'explicit' (default) or 'node'
.
+.It Fl -experimental-json-modules
+Enable experimental JSON interop support for the ES Module loader.
+.
.It Fl -experimental-modules
Enable experimental ES module support and caching modules.
.