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

Function resolveWorkspaceImport

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

Source from the content-addressed store, hash-verified

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