({
importer,
importSpecifier,
exportConditions,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
modulePaths,
rootDir,
ignoreSideEffectsForRoot,
allowExportsFolderMapping
})
| 103 | } |
| 104 | |
| 105 | async function resolveWithExportMap({ |
| 106 | importer, |
| 107 | importSpecifier, |
| 108 | exportConditions, |
| 109 | packageInfoCache, |
| 110 | extensions, |
| 111 | mainFields, |
| 112 | preserveSymlinks, |
| 113 | useBrowserOverrides, |
| 114 | baseDir, |
| 115 | moduleDirectories, |
| 116 | modulePaths, |
| 117 | rootDir, |
| 118 | ignoreSideEffectsForRoot, |
| 119 | allowExportsFolderMapping |
| 120 | }) { |
| 121 | if (importSpecifier.startsWith('#')) { |
| 122 | // this is a package internal import, resolve using package imports field |
| 123 | const resolveResult = await resolvePackageImports({ |
| 124 | importSpecifier, |
| 125 | importer, |
| 126 | moduleDirs: moduleDirectories, |
| 127 | conditions: exportConditions, |
| 128 | // Resolve targets of "imports" mappings using the same algorithm |
| 129 | // we use for normal specifiers: try export maps first and then |
| 130 | // fall back to classic resolution. This is important for cases |
| 131 | // like "#foo/*": "@scope/pkg/*" where the target package relies |
| 132 | // on "exports" to expose subpaths. Using the classic resolver |
| 133 | // alone would fail to find those subpaths. |
| 134 | resolveId(id /* , parent*/) { |
| 135 | return resolveImportSpecifiers({ |
| 136 | importer, |
| 137 | importSpecifierList: [id], |
| 138 | exportConditions, |
| 139 | // pass-through of the rest of the context |
| 140 | packageInfoCache, |
| 141 | extensions, |
| 142 | mainFields, |
| 143 | preserveSymlinks, |
| 144 | useBrowserOverrides, |
| 145 | baseDir, |
| 146 | moduleDirectories, |
| 147 | modulePaths, |
| 148 | rootDir, |
| 149 | ignoreSideEffectsForRoot, |
| 150 | allowExportsFolderMapping |
| 151 | }); |
| 152 | } |
| 153 | }); |
| 154 | |
| 155 | if (resolveResult == null) { |
| 156 | // When the target of an "imports" mapping cannot be resolved, |
| 157 | // surface a proper resolve error instead of throwing from |
| 158 | // fileURLToPath(null). |
| 159 | throw new ResolveError( |
| 160 | `Could not resolve import "${importSpecifier}" in ${importer} using imports.` |
| 161 | ); |
| 162 | } |
no test coverage detected