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

Function resolveWorkspaceImport

src/resolution/workspace-packages.ts:702–715  ·  view source on GitHub ↗
(
  importPath: string,
  ws: WorkspacePackages,
  fromFile?: string
)

Source from the content-addressed store, hash-verified

700 * above it declare. Returns `null` when no package name matches.
701 */
702export function resolveWorkspaceImport(
703 importPath: string,
704 ws: WorkspacePackages,
705 fromFile?: string
706): string | null {
707 const hit = matchPackage(importPath, ws, fromFile);
708 if (!hit) return null;
709 const subpath = importPath.slice(hit.name.length); // '' or '/widgets'
710 // A bare member import resolves straight to the member's declared entry
711 // file when the ohpm manifest names one — the caller's exact-path check
712 // hits it without extension/index guessing.
713 const ohpm = subpath ? undefined : ws.entryByName?.get(hit.name);
714 return ohpm ?? (hit.dir + subpath).replace(/\/{2,}/g, '/');
715}
716
717/**
718 * Where an import of a package of the project lands (see

Callers 1

isExternalImportFunction · 0.90

Calls 2

matchPackageFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected