@@ -471,22 +471,6 @@ These CommonJS variables are not available in ES modules.
471471` __filename` and ` __dirname` use cases can be replicated via
472472[` import.meta.url` ][].
473473
474- #### No JSON Module Loading
475-
476- JSON imports are still experimental and only supported via the
477- ` --experimental-json-modules` flag.
478-
479- Local JSON files can be loaded relative to ` import.meta.url` with ` fs` directly:
480-
481- <!-- eslint-skip -->
482-
483- ` ` ` js
484- import { readFile } from ' fs/promises' ;
485- const json = JSON .parse (await readFile (new URL (' ./dat.json' , import .meta.url)));
486- ` ` `
487-
488- Alternatively ` module .createRequire ()` can be used.
489-
490474#### No Native Module Loading
491475
492476Native modules are not currently supported with ES module imports.
@@ -524,35 +508,19 @@ separate cache.
524508
525509> Stability: 1 - Experimental
526510
527- Currently importing JSON modules are only supported in the ` commonjs` mode
528- and are loaded using the CJS loader. [WHATWG JSON modules specification][] are
529- still being standardized, and are experimentally supported by including the
530- additional flag ` --experimental-json-modules` when running Node.js.
531-
532- When the ` --experimental-json-modules` flag is included, both the
533- ` commonjs` and ` module` mode use the new experimental JSON
534- loader. The imported JSON only exposes a ` default ` . There is no
535- support for named exports. A cache entry is created in the CommonJS
536- cache to avoid duplication. The same object is returned in
537- CommonJS if the JSON module has already been imported from the
538- same path.
539-
540- Assuming an ` index.mjs` with
511+ JSON files can be referenced by ` import` :
541512
542513` ` ` js
543514import packageConfig from ' ./package.json' assert { type : 'json ' };
544515` ` `
545516
546- The ` -- experimental- json- modules` flag is needed for the module
547- to work.
548-
549- ` ` ` bash
550- node index .mjs # fails
551- node -- experimental- json- modules index .mjs # works
552- ` ` `
553-
554517The ` assert { type: ' json' }` syntax is mandatory; see [Import Assertions][].
555518
519+ The imported JSON only exposes a ` default` export. There is no support for named
520+ exports. A cache entry is created in the CommonJS cache to avoid duplication.
521+ The same object is returned in CommonJS if the JSON module has already been
522+ imported from the same path.
523+
556524<i id="esm_experimental_wasm_modules"></i>
557525
558526## Wasm modules
@@ -1467,7 +1435,6 @@ success!
14671435[Node .js Module Resolution Algorithm]: #resolver- algorithm- specification
14681436[Terminology]: #terminology
14691437[URL ]: https: // url.spec.whatwg.org/
1470- [WHATWG JSON modules specification]: https: // html.spec.whatwg.org/#creating-a-json-module-script
14711438[` "exports"` ]: packages .md #exports
14721439[` "type"` ]: packages .md #type
14731440[` --input-type` ]: cli .md #-- input- typetype
0 commit comments