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

vm: perform lazy-loading at top level #53587

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 5 additions & 3 deletions lib/internal/vm/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
emitExperimentalWarning,
getConstructorOf,
kEmptyObject,
getLazy,
} = require('internal/util');
const {
ERR_INVALID_ARG_TYPE,
Expand Down Expand Up @@ -82,6 +83,9 @@ const kLink = Symbol('kLink');

const { isContext } = require('internal/vm');

// Lazy to prevent a circular dependency
const inspectLazy = getLazy(() => require('internal/util/inspect').inspect);

function isModule(object) {
if (typeof object !== 'object' || object === null || !ObjectPrototypeHasOwnProperty(object, kWrap)) {
return false;
Expand Down Expand Up @@ -245,9 +249,7 @@ class Module {
configurable: true,
});

// Lazy to avoid circular dependency
const { inspect } = require('internal/util/inspect');
return inspect(o, { ...options, customInspect: false });
return inspectLazy()(o, { ...options, customInspect: false });
}
}

Expand Down
Loading