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

Commit

Permalink
deprecate json translator
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored and MylesBorins committed Sep 12, 2018
1 parent f0ca33c commit 5adac3c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
3 changes: 1 addition & 2 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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][] |

Expand Down
17 changes: 0 additions & 17 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
});

0 comments on commit 5adac3c

Please sign in to comment.