diff --git a/doc/api/esm.md b/doc/api/esm.md index 459f877718..a1dfae6931 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -86,7 +86,7 @@ For now, only modules using the `file:` protocol can be loaded. ## Interop with existing modules -All CommonJS, JSON, and C++ modules can be used with `import`. +CommonJS and C++ modules can be used with `import`. Modules loaded this way will only be loaded once, even if their query or fragment string differs between `import` statements. @@ -176,7 +176,6 @@ module. This can be one of the following: | `'esm'` | Load a standard JavaScript module | | `'cjs'` | Load a node-style CommonJS module | | `'builtin'` | Load a node builtin CommonJS module | -| `'json'` | Load a JSON file | | `'addon'` | Load a [C++ Addon][addons] | | `'dynamic'` | Use a [dynamic instantiate hook][] | diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index aaf35ed461..ff909c248f 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -86,20 +86,3 @@ translators.set('addon', async (url) => { reflect.exports.default.set(module.exports); }); }); - -// Strategy for loading a JSON file -translators.set('json', async (url) => { - debug(`Translating JSONModule ${url}`); - return createDynamicModule(['default'], url, (reflect) => { - debug(`Loading JSONModule ${url}`); - const pathname = internalURLModule.fileURLToPath(new URL(url)); - const content = readFileSync(pathname, 'utf8'); - try { - const exports = JsonParse(stripBOM(content)); - reflect.exports.default.set(exports); - } catch (err) { - err.message = pathname + ': ' + err.message; - throw err; - } - }); -});