* `target` as a file the index holds: as written, with the language's * extensions or index files, or as the source of an emitted `.js`. Only the * index counts: build output a developer has built locally is on disk, but * nothing links to it.
(target: string, language: Language, context: ResolutionContext)
| 1657 | * nothing links to it. |
| 1658 | */ |
| 1659 | function indexedTarget(target: string, language: Language, context: ResolutionContext): string | null { |
| 1660 | const indexed = (file: string): boolean => context.isIndexedFile?.(file) ?? context.fileExists(file); |
| 1661 | const asIs = indexedSpelling(target, language); |
| 1662 | if (indexed(asIs)) return asIs; |
| 1663 | for (const ext of EXTENSION_RESOLUTION[language] || []) { |
| 1664 | const candidate = indexedSpelling(target + ext, language); |
| 1665 | if (indexed(candidate)) return candidate; |
| 1666 | } |
| 1667 | return findSourceForEmittedSpecifier(asIs, language, context, indexed); |
| 1668 | } |
| 1669 | |
| 1670 | /** A package's build folder: `dist/`, `build/`, `lib/`, `out/`, `es/`, `esm/`, `cjs/`. */ |
| 1671 | const BUILD_ROOT = /^(?:dist|build|lib|out|output|es|esm|cjs|umd)\//; |
no test coverage detected