MCPcopy Create free account
hub / github.com/GNOME/gjs / resolveSpecifier

Method resolveSpecifier

modules/internal/internalLoader.js:94–112  ·  view source on GitHub ↗

* Resolves an import specifier given an optional parent importer. * * @param {string} specifier the import specifier * @param {Uri | null} [parentURI] the URI of the module importing the specifier * @returns {Uri}

(specifier, parentURI = null)

Source from the content-addressed store, hash-verified

92 * @returns {Uri}
93 */
94 resolveSpecifier(specifier, parentURI = null) {
95 try {
96 const uri = parseURI(specifier);
97
98 if (uri)
99 return uri;
100 } catch {
101 // If it can't be parsed as a URI, try a relative path or return null.
102 }
103
104 if (isRelativePath(specifier)) {
105 if (!parentURI)
106 throw new ImportError('Cannot import relative path when module path is unknown.');
107
108 return resolveRelativeResourceOrFile(parentURI.uriWithQuery, specifier);
109 }
110
111 throw new ImportError(`Module not found: ${specifier}`);
112 }
113
114 /**
115 * Compiles a module source text with the module's URI

Callers 1

resolveModuleMethod · 0.95

Calls 1

isRelativePathFunction · 0.85

Tested by

no test coverage detected