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

Function indexedTarget

src/resolution/import-resolver.ts:1598–1607  ·  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

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

Callers 2

declaredWorkspaceEntryFunction · 0.85
builtSourceOfFunction · 0.85

Calls 3

indexedSpellingFunction · 0.85
indexedFunction · 0.70

Tested by

no test coverage detected