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

Function cjsEmplaceModuleCacheEntry

lib/internal/modules/esm/translators.js:398–412  ·  view source on GitHub ↗

* Get or create an entry in the CJS module cache for the given filename. * @param {string} filename CJS module filename * @param {CJSModule} parent The parent CJS module * @returns {CJSModule} the cached CJS module entry

(filename, parent)

Source from the content-addressed store, hash-verified

396 * @returns {CJSModule} the cached CJS module entry
397 */
398function cjsEmplaceModuleCacheEntry(filename, parent) {
399 // TODO: Do we want to keep hitting the user mutable CJS loader here?
400 let cjsMod = CJSModule._cache[filename];
401 if (cjsMod) {
402 return cjsMod;
403 }
404
405 cjsMod = new CJSModule(filename, parent);
406 cjsMod.filename = filename;
407 cjsMod.paths = CJSModule._nodeModulePaths(cjsMod.path);
408 cjsMod[kIsCachedByESMLoader] = true;
409 CJSModule._cache[filename] = cjsMod;
410
411 return cjsMod;
412}
413
414/**
415 * Pre-parses a CommonJS module's exports and re-exports.

Callers 3

requireFnFunction · 0.85
cjsPreparseModuleExportsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…