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

Function getDefaultLoad

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

* Construct a last nextLoad() for load hooks invoked for the CJS loader. * @param {string} url URL passed from the hook. * @param {string} filename Filename inferred from the URL. * @returns {(url: string, context: ModuleLoadContext) => ModuleLoadResult}

(url, filename)

Source from the content-addressed store, hash-verified

1261 * @returns {(url: string, context: ModuleLoadContext) => ModuleLoadResult}
1262 */
1263function getDefaultLoad(url, filename) {
1264 return function defaultLoad(urlFromHook, context) {
1265 // If the url is the same as the original one, save the conversion.
1266 const isLoadingOriginalModule = (urlFromHook === url);
1267 const filenameFromHook = isLoadingOriginalModule ? filename : convertURLToCJSFilename(urlFromHook);
1268 const source = defaultLoadImpl(filenameFromHook, context.format);
1269 // Format from context is directly returned, because format detection should only be
1270 // done after the entire load chain is completed.
1271 return { source, format: context.format };
1272 };
1273}
1274
1275/**
1276 * Load a specified builtin module, invoking load hooks if necessary.

Callers 2

loadBuiltinWithHooksFunction · 0.85
loadSourceFunction · 0.85

Calls 2

convertURLToCJSFilenameFunction · 0.85
defaultLoadImplFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…