exportsOf
What a package exports: each exported name, with the subpath it's exported from.
import { absolute, owns, within } from "#codebase/tcmts/cli/manifests"; import type { Pkg } from "#codebase/tcmts/cli/manifests"; import type { NameRow } from "#codebase/tcmts/store"; export function exportsOf(pkg: Pkg, all: Pkg[], rows: NameRow[]): Map<string, string> { const out = new Map<string, string>(); for (const [sub, targets] of Object.entries(pkg.manifest.exports)) { for (const t of targets) { const abs = absolute(pkg.namespace, t); const hit = rows.filter((r) => within(abs, r.path) && owns(pkg, all, r.path)); if (!hit.length) throw new Error(`${pkg.manifestPath}: exports["${sub}"] names '${t}', which isn't in ${pkg.namespace || "the codebase"}`); for (const r of hit) if (!out.has(r.path)) out.set(r.path, sub); } } return out; }
uses
- tcmts.cli.manifests.Pkg
- tcmts.cli.manifests.absolute
- tcmts.cli.manifests.owns
- tcmts.cli.manifests.within
- tcmts.store.NameRow