From 5adac3c5f70638982bb4f76e35c3cc03a0438391 Mon Sep 17 00:00:00 2001 From: guybedford Date: Tue, 28 Aug 2018 17:53:41 +0200 Subject: [PATCH] deprecate json translator --- doc/api/esm.md | 3 +-- lib/internal/modules/esm/translators.js | 17 ----------------- 2 files changed, 1 insertion(+), 19 deletions(-) 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; - } - }); -});