Skip to main content

Module require_resolve

Module require_resolve 

Source
Expand description

Node’s require.resolve: a specifier plus the directory it was written in, answered as an absolute path.

Host-neutral on purpose. The algorithm is Node’s and belongs here; WHO is asking — which file a bundled frame came from, which specifiers the runtime serves natively — is the host’s to decide, so nothing in this module looks at a Ctx or knows a builtin from a package.

Node’s algorithm, minus the parts that cannot exist here. It reports a path and nothing else — unlike a loader, which resolves a specifier in order to LOAD it and can therefore insist the target is ESM. require.resolve('./legacy.cjs') is a legitimate question with a legitimate answer, so nothing here inspects module format.

Not implemented, and documented rather than faked: require.resolve’s { paths } option and require.resolve.paths(). Both describe a module search path this runtime does not have.

Hand-written rather than vendored: upstream llrt is ESM-only and has no require, let alone require.resolve.

Functions§

resolve
Resolve specifier as written in a file inside base_dir.