Skip to content

Commit f7c1015

Browse files
daeyeondanielleadams
authored andcommitted
lib: disambiguate native module to builtin module
Signed-off-by: Daeyeon Jeong <[email protected]> PR-URL: #45673 Refs: #44135 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 899ba3d commit f7c1015

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/internal/bootstrap/loaders.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const schemelessBlockList = new SafeSet([
144144
'DEP0111');
145145
}
146146
if (legacyWrapperList.has(module)) {
147-
return nativeModuleRequire('internal/legacy/processbinding')[module]();
147+
return requireBuiltin('internal/legacy/processbinding')[module]();
148148
}
149149
return internalBinding(module);
150150
}
@@ -285,14 +285,14 @@ class BuiltinModule {
285285
// TODO(aduh95): move this to C++, alongside the initialization of the class.
286286
ObjectSetPrototypeOf(ModuleWrap.prototype, null);
287287
const url = `node:${this.id}`;
288-
const nativeModule = this;
288+
const builtin = this;
289289
const exportsKeys = ArrayPrototypeSlice(this.exportKeys);
290290
ArrayPrototypePush(exportsKeys, 'default');
291291
this.module = new ModuleWrap(
292292
url, undefined, exportsKeys,
293293
function() {
294-
nativeModule.syncExports();
295-
this.setExport('default', nativeModule.exports);
294+
builtin.syncExports();
295+
this.setExport('default', builtin.exports);
296296
});
297297
// Ensure immediate sync execution to capture exports now
298298
this.module.instantiate();
@@ -326,7 +326,7 @@ class BuiltinModule {
326326

327327
try {
328328
const requireFn = StringPrototypeStartsWith(this.id, 'internal/deps/') ?
329-
requireWithFallbackInDeps : nativeModuleRequire;
329+
requireWithFallbackInDeps : requireBuiltin;
330330

331331
const fn = compileFunction(id);
332332
// Arguments must match the parameters specified in
@@ -350,10 +350,10 @@ class BuiltinModule {
350350
const loaderExports = {
351351
internalBinding,
352352
BuiltinModule,
353-
require: nativeModuleRequire
353+
require: requireBuiltin
354354
};
355355

356-
function nativeModuleRequire(id) {
356+
function requireBuiltin(id) {
357357
if (id === loaderId) {
358358
return loaderExports;
359359
}
@@ -371,7 +371,7 @@ function requireWithFallbackInDeps(request) {
371371
if (!BuiltinModule.map.has(request)) {
372372
request = `internal/deps/${request}`;
373373
}
374-
return nativeModuleRequire(request);
374+
return requireBuiltin(request);
375375
}
376376

377377
// Pass the exports back to C++ land for C++ internals to use.

0 commit comments

Comments
 (0)