Skip to content

Commit

Permalink
doc: esm loader example with module.builtinModules
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
guybedford authored and gibfahn committed Dec 20, 2017
1 parent 92fbf38 commit 101b0c7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 101b0c7

Please sign in to comment.