@@ -409,18 +409,11 @@ fs.readFileSync = () => Buffer.from('Hello, ESM');
409
409
fs .readFileSync === readFileSync;
410
410
` ` `
411
411
412
- ## Experimental JSON Modules
412
+ ## JSON Modules
413
413
414
- **Note: This API is still being designed and is subject to change.**
414
+ JSON modules follow the [WHATWG JSON modules specification][].
415
415
416
- Currently importing JSON modules are only supported in the ` commonjs` mode
417
- and are loaded using the CJS loader. [WHATWG JSON modules][] are currently
418
- being standardized, and are experimentally supported by including the
419
- additional flag ` -- experimental- json- modules` when running Node.js.
420
-
421
- When the ` -- experimental- json- modules` flag is included both the
422
- ` commonjs` and ` module ` mode will use the new experimental JSON
423
- loader. The imported JSON only exposes a ` default` , there is no
416
+ The imported JSON only exposes a ` default` . There is no
424
417
support for named exports. A cache entry is created in the CommonJS
425
418
cache, to avoid duplication. The same object will be returned in
426
419
CommonJS if the JSON module has already been imported from the
@@ -433,14 +426,6 @@ Assuming an `index.mjs` with
433
426
import packageConfig from ' ./package.json' ;
434
427
` ` `
435
428
436
- The ` -- experimental- json- modules` flag is needed for the module
437
- to work.
438
-
439
- ` ` ` bash
440
- node -- experimental- modules index .mjs # fails
441
- node -- experimental- modules -- experimental- json- modules index .mjs # works
442
- ` ` `
443
-
444
429
## Experimental Wasm Modules
445
430
446
431
Importing Web Assembly modules is supported under the
@@ -763,7 +748,7 @@ success!
763
748
[CommonJS]: modules.html
764
749
[ECMAScript-modules implementation]: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md
765
750
[Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md
766
- [WHATWG JSON modules]: https://github.com/ whatwg/html/issues/4315
751
+ [WHATWG JSON modules specification ]: https://html.spec. whatwg.org/#creating-a-json-module-script
767
752
[ES Module Integration Proposal for Web Assembly]: https://github.com/webassembly/esm-integration
768
753
[dynamic instantiate hook]: #esm_dynamic_instantiate_hook
769
754
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
0 commit comments