Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b015747

Browse filesBrowse files
guybedfordMylesBorins
authored andcommitted
doc: esm loader example with module.builtinModules
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>
1 parent 8c21430 commit b015747
Copy full SHA for b015747

File tree

Expand file treeCollapse file tree

1 file changed

+3
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-5
lines changed
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+3-5Lines changed: 3 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,13 @@ be written:
147147
import url from 'url';
148148
import path from 'path';
149149
import process from 'process';
150+
import Module from 'module';
150151

151-
const builtins = new Set(
152-
Object.keys(process.binding('natives')).filter((str) =>
153-
/^(?!(?:internal|node|v8)\/)/.test(str))
154-
);
152+
const builtins = Module.builtinModules;
155153
const JS_EXTENSIONS = new Set(['.js', '.mjs']);
156154

157155
export function resolve(specifier, parentModuleURL/*, defaultResolve */) {
158-
if (builtins.has(specifier)) {
156+
if (builtins.includes(specifier)) {
159157
return {
160158
url: specifier,
161159
format: 'builtin'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.