MCPcopy Index your code
hub / github.com/nodejs/node / defaultResolveImplForCJSLoading

Function defaultResolveImplForCJSLoading

lib/internal/modules/cjs/loader.js:1134–1147  ·  view source on GitHub ↗

* See resolveForCJSWithHooks. * @param {string} specifier * @param {Module|undefined} parent * @param {boolean} isMain * @param {ResolveFilenameOptions} options * @returns {{url?: string, format?: string, parentURL?: string, filename: string}}

(specifier, parent, isMain, options)

Source from the content-addressed store, hash-verified

1132 * @returns {{url?: string, format?: string, parentURL?: string, filename: string}}
1133 */
1134function defaultResolveImplForCJSLoading(specifier, parent, isMain, options) {
1135 // For backwards compatibility, when encountering requests starting with node:,
1136 // throw ERR_UNKNOWN_BUILTIN_MODULE on failure or return the normalized ID on success
1137 // without going into Module._resolveFilename.
1138 let normalized;
1139 if (StringPrototypeStartsWith(specifier, 'node:')) {
1140 normalized = BuiltinModule.normalizeRequirableId(specifier);
1141 if (!normalized) {
1142 throw new ERR_UNKNOWN_BUILTIN_MODULE(specifier);
1143 }
1144 return { __proto__: null, url: specifier, format: 'builtin', filename: normalized };
1145 }
1146 return wrapResolveFilename(specifier, parent, isMain, options);
1147}
1148
1149/**
1150 * @typedef {{

Callers

nothing calls this directly

Calls 2

wrapResolveFilenameFunction · 0.85
normalizeRequirableIdMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…