MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / ESM_RESOLVE

Method ESM_RESOLVE

tools/mcpack.js:711–732  ·  view source on GitHub ↗
(specifier, parentURL)

Source from the content-addressed store, hash-verified

709 }
710
711 ESM_RESOLVE(specifier, parentURL) {
712 let resolved = this.validateURL(specifier);
713 if (!resolved) {
714 if (specifier.startsWith('/') || specifier.startsWith('./') || specifier.startsWith('../'))
715 resolved = this.mergeURL(specifier, parentURL);
716 else if (specifier.startsWith('#'))
717 resolved = this.PACKAGE_IMPORTS_RESOLVE(specifier, parentURL, defaultConditions);
718 else
719 resolved = this.PACKAGE_RESOLVE(specifier, parentURL);
720 }
721 if (resolved.startsWith("file://")) {
722 if ((resolved.indexOf("%2F") >= 0) || (resolved.indexOf("%5C") >= 0))
723 this.throwInvalidModuleSpecifierError();
724 let path = this.urlToFilePath(resolved);
725 if (!path)
726 this.throwModuleNotFoundError();
727 let format = this.ESM_FILE_FORMAT(resolved);
728 if ((format !== "module") && (format !== "json"))
729 this.throwUnsupportedModuleFormat(format);
730 }
731 return resolved;
732 }
733 PACKAGE_RESOLVE(packageSpecifier, parentURL) {
734 let packageName;
735 if (packageSpecifier === "")

Callers 2

parseModuleMethod · 0.80
runMethod · 0.80

Calls 9

validateURLMethod · 0.80
mergeURLMethod · 0.80
PACKAGE_RESOLVEMethod · 0.80
urlToFilePathMethod · 0.80
ESM_FILE_FORMATMethod · 0.80

Tested by

no test coverage detected