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