From a63df2129c84c3b7b286181f01cadf499d17a611 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sat, 29 Jan 2022 18:25:39 -0800 Subject: [PATCH] fixup! module: unflag esm json modules --- doc/api/cli.md | 2 +- doc/api/esm.md | 18 +----------------- test/es-module/test-esm-json.mjs | 1 - 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 76c122fc16dd0b..be03f2bbaa37f4 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -296,7 +296,7 @@ Enable experimental `import.meta.resolve()` support. added: v12.9.0 --> -Enable experimental JSON support for the ES Module loader. +This option is a no-op. It is kept for compatibility. ### `--experimental-loader=module` diff --git a/doc/api/esm.md b/doc/api/esm.md index ec1814ef3d567e..5d0c99ab34007d 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -477,22 +477,6 @@ These CommonJS variables are not available in ES modules. `__filename` and `__dirname` use cases can be replicated via [`import.meta.url`][]. -#### No JSON Module Loading - -JSON imports are still experimental and only supported via the -`--experimental-json-modules` flag. - -Local JSON files can be loaded relative to `import.meta.url` with `fs` directly: - - - -```js -import { readFile } from 'fs/promises'; -const json = JSON.parse(await readFile(new URL('./dat.json', import.meta.url))); -``` - -Alternatively `module.createRequire()` can be used. - #### No Native Module Loading Native modules are not currently supported with ES module imports. @@ -538,7 +522,7 @@ import packageConfig from './package.json' assert { type: 'json' }; The `assert { type: 'json' }` syntax is mandatory; see [Import Assertions][]. -The imported JSON only exposes a `default`. There is no support for named +The imported JSON only exposes a `default` export. There is no support for named exports. A cache entry is created in the CommonJS cache to avoid duplication. The same object is returned in CommonJS if the JSON module has already been imported from the same path. diff --git a/test/es-module/test-esm-json.mjs b/test/es-module/test-esm-json.mjs index e19762c6e61a71..6d55419eedc857 100644 --- a/test/es-module/test-esm-json.mjs +++ b/test/es-module/test-esm-json.mjs @@ -9,7 +9,6 @@ strictEqual(secret.ofLife, 42); // Test warning message const child = spawn(process.execPath, [ - '--experimental-json-modules', path('/es-modules/json-modules.mjs'), ]);