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

Method getOrCreateModuleJob

lib/internal/modules/esm/loader.js:599–617  ·  view source on GitHub ↗

* Get a (possibly not yet fully linked) module job from the cache, or create one and return its Promise. * @param {string} [parentURL] The URL of the module where the module request is initiated. * It's undefined if it's from the root module. * @param {ModuleRequest} request Module reques

(parentURL, request, requestType)

Source from the content-addressed store, hash-verified

597 * @returns {Promise<ModuleJobBase>|ModuleJobBase}
598 */
599 getOrCreateModuleJob(parentURL, request, requestType) {
600 let maybePromise;
601 if (requestType === kRequireInImportedCJS || requestType === kImportInRequiredESM) {
602 // In these two cases, resolution must be synchronous.
603 maybePromise = this.resolveSync(parentURL, request);
604 assert(!isPromise(maybePromise));
605 } else {
606 maybePromise = this.#resolve(parentURL, request);
607 }
608
609 const afterResolve = (resolveResult) => {
610 return this.#getOrCreateModuleJobAfterResolve(parentURL, resolveResult, request, requestType);
611 };
612
613 if (isPromise(maybePromise)) {
614 return PromisePrototypeThen(maybePromise, afterResolve);
615 }
616 return afterResolve(maybePromise);
617 }
618
619 /**
620 * This method is usually called indirectly as part of the loading processes.

Callers 4

importMethod · 0.95
syncLinkMethod · 0.80
#asyncLinkMethod · 0.80
requireFnFunction · 0.80

Calls 3

resolveSyncMethod · 0.95
#resolveMethod · 0.95
assertFunction · 0.50

Tested by

no test coverage detected