MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / indexedTarget

Function indexedTarget

src/resolution/import-resolver.ts:1659–1668  ·  view source on GitHub ↗

* `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)

Source from the content-addressed store, hash-verified

1657 * nothing links to it.
1658 */
1659function 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/`. */
1671const BUILD_ROOT = /^(?:dist|build|lib|out|output|es|esm|cjs|umd)\//;

Callers 3

relativeDirectoryMainFunction · 0.85
declaredWorkspaceEntryFunction · 0.85
builtSourceOfFunction · 0.85

Calls 3

indexedSpellingFunction · 0.85
indexedFunction · 0.70

Tested by

no test coverage detected