Skip to content

Commit

Permalink
fixup! module: unflag esm json modules
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed Jan 31, 2022
1 parent 5fe4f32 commit a63df21
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/api/cli.md
Expand Up @@ -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`

Expand Down
18 changes: 1 addition & 17 deletions doc/api/esm.md
Expand Up @@ -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:
<!-- eslint-skip -->
```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.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion test/es-module/test-esm-json.mjs
Expand Up @@ -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'),
]);

Expand Down

0 comments on commit a63df21

Please sign in to comment.