lib/import-graph
lib/import-graph.js
Functions(6)
@param {string} file @returns {ts.ScriptKind}
| Parameter | Type | Optional | Description |
|---|---|---|---|
file | any |
Returns:
any Signature
getScriptKind(file: any): any
Extract raw import/require specifiers (module paths exactly as written in
source) for one file. Handles ESM `import ... from "x"` / `export ...
from "x"`, CommonJS `require("x")`, and best-effort dynamic `import("x")`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
filePath | string |
Returns:
string[] — raw specifiers, e.g. ["./coverage.js", "typescript"]Signature
extractSpecifiers(filePath: any): any
Resolve a raw specifier (as written in `fromFile`) to an absolute path,
but only if it lands on one of `knownFilesSet` -- external packages
(non-relative specifiers, or relative specifiers that resolve outside the
analyzed set) are not graph nodes.
| Parameter | Type | Optional | Description |
|---|---|---|---|
spec | string | ||
fromFile | string | ||
knownFilesSet | Set<string> |
Returns:
string|null Signature
resolveSpecifier(spec: any, fromFile: any, knownFilesSet: any): any
Build a project-wide import graph across `files`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
files | string[] | - file paths (same set the caller already collected via collectFiles). |
Returns:
{edges: {from:string,to:string}[], inDegree: Object<string,number>} Signature
buildImportGraph(files: any): any
Files with zero incoming imports that are not among the known entry points.
| Parameter | Type | Optional | Description |
|---|---|---|---|
graph | {edges: Array, inDegree: Object<string,number>} | ||
entryPoints | string[] | - known entry-point file paths (bin scripts, package.json main/exports targets). |
Returns:
string[] — orphan file paths, sorted.Signature
findOrphanFiles(graph: any, entryPoints: any): any
Variables & Constants(19)
const fs: any
constlib/import-graph.js
----------------------------------------
Project-wide import graph + orphan-file detection, for the internal
project dashboard (Track B, see docs/backlog/adr-phase-j-project-dashboard.md).
CORRECTION (caught during implementation, see task-pj-01-import-graph.md):
the ADR and story-code-health-dashboard both assumed this module would
"reuse lib/extractor.js's existing per-file import/export data." That
data does not exist -- extractModule() (lib/extractor.js) returns
{ filePath, moduleName, description, since, functions, classes,
interfaces, typeAliases, enums, variables } with no imports/exports
field. This module does its own lightweight extraction instead, using
the `typescript` compiler API -- the same parser lib/extractor.js
already uses, so it is zero NEW dependency, just not zero new parsing
as originally (incorrectly) assumed.
Signature
const fs: any