* `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)
| 1596 | * nothing links to it. |
| 1597 | */ |
| 1598 | function indexedTarget(target: string, language: Language, context: ResolutionContext): string | null { |
| 1599 | const indexed = (file: string): boolean => context.isIndexedFile?.(file) ?? context.fileExists(file); |
| 1600 | const asIs = indexedSpelling(target, language); |
| 1601 | if (indexed(asIs)) return asIs; |
| 1602 | for (const ext of EXTENSION_RESOLUTION[language] || []) { |
| 1603 | const candidate = indexedSpelling(target + ext, language); |
| 1604 | if (indexed(candidate)) return candidate; |
| 1605 | } |
| 1606 | return findSourceForEmittedSpecifier(asIs, language, context, indexed); |
| 1607 | } |
| 1608 | |
| 1609 | /** A package's build folder: `dist/`, `build/`, `lib/`, `out/`, `es/`, `esm/`, `cjs/`. */ |
| 1610 | const BUILD_ROOT = /^(?:dist|build|lib|out|output|es|esm|cjs|umd)\//; |
no test coverage detected