* @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)
| 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(). |
no test coverage detected