summaryrefslogtreecommitdiff
path: root/doc/api/esm.md
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2017-11-29 10:58:11 +0200
committerAnatoli Papirovski <apapirovski@mac.com>2017-12-09 15:12:05 -0500
commitefc38592ccc4b8f4a1e59fc7f13d7a37d9d3c4a6 (patch)
treeea6507a40069aae170cf96872a848ed689d9be54 /doc/api/esm.md
parent7db53706c9aa44aa645a410cd48cf23cf1f300fd (diff)
downloadnode-new-efc38592ccc4b8f4a1e59fc7f13d7a37d9d3c4a6.tar.gz
doc: esm loader example with module.builtinModules
PR-URL: https://github.com/nodejs/node/pull/17385 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'doc/api/esm.md')
-rw-r--r--doc/api/esm.md8
1 files changed, 3 insertions, 5 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index c352c24aa1..b812d7cb76 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -147,15 +147,13 @@ be written:
import url from 'url';
import path from 'path';
import process from 'process';
+import Module from 'module';
-const builtins = new Set(
- Object.keys(process.binding('natives')).filter((str) =>
- /^(?!(?:internal|node|v8)\/)/.test(str))
-);
+const builtins = Module.builtinModules;
const JS_EXTENSIONS = new Set(['.js', '.mjs']);
export function resolve(specifier, parentModuleURL/*, defaultResolve */) {
- if (builtins.has(specifier)) {
+ if (builtins.includes(specifier)) {
return {
url: specifier,
format: 'builtin'