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

Method resolveModule

modules/internal/internalLoader.js:136–160  ·  view source on GitHub ↗

* @param {string} specifier the specifier (e.g. relative path, root package) to resolve * @param {Uri | null} importingModuleURI the URI of the module * triggering this resolve * * @returns {ResolvedModule}

(specifier, importingModuleURI)

Source from the content-addressed store, hash-verified

134 * @returns {ResolvedModule}
135 */
136 resolveModule(specifier, importingModuleURI) {
137 const registry = getRegistry(this.global);
138
139 // Check if the module has already been loaded
140 let module = registry.get(specifier);
141 if (module)
142 return [module, '', ''];
143
144 // 1) Resolve path and URI-based imports.
145 const uri = this.resolveSpecifier(specifier, importingModuleURI);
146
147 module = registry.get(uri.uriWithQuery);
148
149 // Check if module is already loaded (relative handling)
150 if (module)
151 return [module, '', ''];
152
153 const text = this.loadURI(uri);
154 const internal = this.isInternal(uri);
155 const priv = new ModulePrivate(uri.uriWithQuery, uri.uri, internal);
156 const compiled = this.compileModule(priv, text);
157
158 registry.set(uri.uriWithQuery, compiled);
159 return [compiled, text, uri.uri];
160 }
161
162 /**
163 * Called by SpiderMonkey as part of gjs_module_resolve().

Callers 2

moduleResolveHookMethod · 0.95
moduleResolveHookMethod · 0.80

Calls 6

resolveSpecifierMethod · 0.95
loadURIMethod · 0.95
isInternalMethod · 0.95
compileModuleMethod · 0.95
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected