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

Function wrapModuleLoad

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

* Internal method to add tracing capabilities for Module._load. * * See more Module._load * @returns {object}

(request, parent, isMain, options)

Source from the content-addressed store, hash-verified

241 * @returns {object}
242 */
243function wrapModuleLoad(request, parent, isMain, options) {
244 const logLabel = `[${parent?.id || ''}] [${request}]`;
245 const traceLabel = `require('${request}')`;
246 const channel = onRequire();
247
248 startTimer(logLabel, traceLabel);
249
250 try {
251 if (channel.hasSubscribers) {
252 return onRequire().traceSync(Module._load, {
253 __proto__: null,
254 parentFilename: parent?.filename,
255 id: request,
256 }, Module, request, parent, isMain, options);
257 }
258 // No subscribers, skip the wrapping to avoid clobbering stack traces
259 // and debugging steps.
260 return Module._load(request, parent, isMain, options);
261 } finally {
262 endTimer(logLabel, traceLabel);
263 }
264}
265
266/**
267 * Get a path's properties, using an in-memory cache to minimize lookups.

Callers 5

executeUserEntryPointFunction · 0.85
requireFnFunction · 0.85
loader.jsFile · 0.85

Calls 3

startTimerFunction · 0.85
endTimerFunction · 0.85
traceSyncMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…