Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Commit 5adac3c

Browse files
guybedfordMylesBorins
authored andcommitted
deprecate json translator
1 parent f0ca33c commit 5adac3c

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

doc/api/esm.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ For now, only modules using the `file:` protocol can be loaded.
8686

8787
## Interop with existing modules
8888

89-
All CommonJS, JSON, and C++ modules can be used with `import`.
89+
CommonJS and C++ modules can be used with `import`.
9090

9191
Modules loaded this way will only be loaded once, even if their query
9292
or fragment string differs between `import` statements.
@@ -176,7 +176,6 @@ module. This can be one of the following:
176176
| `'esm'` | Load a standard JavaScript module |
177177
| `'cjs'` | Load a node-style CommonJS module |
178178
| `'builtin'` | Load a node builtin CommonJS module |
179-
| `'json'` | Load a JSON file |
180179
| `'addon'` | Load a [C++ Addon][addons] |
181180
| `'dynamic'` | Use a [dynamic instantiate hook][] |
182181

lib/internal/modules/esm/translators.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,3 @@ translators.set('addon', async (url) => {
8686
reflect.exports.default.set(module.exports);
8787
});
8888
});
89-
90-
// Strategy for loading a JSON file
91-
translators.set('json', async (url) => {
92-
debug(`Translating JSONModule ${url}`);
93-
return createDynamicModule(['default'], url, (reflect) => {
94-
debug(`Loading JSONModule ${url}`);
95-
const pathname = internalURLModule.fileURLToPath(new URL(url));
96-
const content = readFileSync(pathname, 'utf8');
97-
try {
98-
const exports = JsonParse(stripBOM(content));
99-
reflect.exports.default.set(exports);
100-
} catch (err) {
101-
err.message = pathname + ': ' + err.message;
102-
throw err;
103-
}
104-
});
105-
});

0 commit comments

Comments
 (0)