Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc,lib: disambiguate the old term, NativeModule #45673

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lib: disambiguate native module to builtin module
Signed-off-by: Daeyeon Jeong <[email protected]>
  • Loading branch information
daeyeon committed Nov 30, 2022
commit f4d413ecc0aff19398467bc47bd0e0c2cc0a0702
16 changes: 8 additions & 8 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const schemelessBlockList = new SafeSet([
'DEP0111');
}
if (legacyWrapperList.has(module)) {
return nativeModuleRequire('internal/legacy/processbinding')[module]();
return requireBuiltin('internal/legacy/processbinding')[module]();
}
return internalBinding(module);
}
Expand Down Expand Up @@ -285,14 +285,14 @@ class BuiltinModule {
// TODO(aduh95): move this to C++, alongside the initialization of the class.
ObjectSetPrototypeOf(ModuleWrap.prototype, null);
const url = `node:${this.id}`;
const nativeModule = this;
const builtin = this;
const exportsKeys = ArrayPrototypeSlice(this.exportKeys);
ArrayPrototypePush(exportsKeys, 'default');
this.module = new ModuleWrap(
url, undefined, exportsKeys,
function() {
nativeModule.syncExports();
this.setExport('default', nativeModule.exports);
builtin.syncExports();
this.setExport('default', builtin.exports);
});
// Ensure immediate sync execution to capture exports now
this.module.instantiate();
Expand Down Expand Up @@ -326,7 +326,7 @@ class BuiltinModule {

try {
const requireFn = StringPrototypeStartsWith(this.id, 'internal/deps/') ?
requireWithFallbackInDeps : nativeModuleRequire;
requireWithFallbackInDeps : requireBuiltin;

const fn = compileFunction(id);
// Arguments must match the parameters specified in
Expand All @@ -350,10 +350,10 @@ class BuiltinModule {
const loaderExports = {
internalBinding,
BuiltinModule,
require: nativeModuleRequire
require: requireBuiltin
};

function nativeModuleRequire(id) {
function requireBuiltin(id) {
if (id === loaderId) {
return loaderExports;
}
Expand All @@ -371,7 +371,7 @@ function requireWithFallbackInDeps(request) {
if (!BuiltinModule.map.has(request)) {
request = `internal/deps/${request}`;
}
return nativeModuleRequire(request);
return requireBuiltin(request);
}

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