Build dependency graph for all source files
Parses import declarations and export ... from re-exports. Module
specifiers are resolved through the TypeScript module resolver (tsconfig
paths aware) with a relative / index probing fallback.
Clear the dependency graph
Compute transitive dependencies using Floyd-Warshall algorithm
This computes the transitive closure of the dependency graph, allowing efficient queries for all transitive dependents.
Time complexity: O(n³) where n is number of files Space complexity: O(n²)
Note: Only needs to be computed once after building graph.
Detect circular dependencies
Returns sets of files that form circular dependency chains.
Array of circular dependency chains
Find the files consuming specific exported symbols of a file
(TypeScript findReferences).
Get direct dependencies of a file
Returns files that this file directly imports.
Get direct dependents of a file
Returns files that directly import this file.
Get the dependency graph
Compute the build impact of changing the given files.
Unlike getTransitiveDependents, propagation is name-aware:
import type,
import { type X }, or names that resolve to interfaces / type
aliases) are reported as typeOnlyDependents (type-check only, no JS
rebuild); files reached only through type-only edges stay type-only;@NgModule exports; not bodies with a stated return type or
decorators), see export-surface. Side-effect imports propagate with
all exports.Requires buildGraph to have run.
Absolute file paths that change
Optionalsymbols?: string[]Restrict the seed to these exported symbols of the changed files (symbol-level impact)
Get dependency graph statistics
Files whose classes the templates of this file use without importing them. Empty unless template edges are enabled.
Get all transitive dependents of a file
Returns all files that directly or indirectly depend on the given file. Automatically computes transitive dependencies if not already computed.
The file to find dependents for
Array of file paths that depend on this file
Check if there's a dependency path from source to target
Source file path
Target file path
True if source depends on target (directly or transitively)
Dependency graph builder
Builds a directed graph of file dependencies by parsing import statements and
export ... fromre-exports, and computes transitive relationships with the Floyd-Warshall algorithm. DependencyGraphBuilder.getImpact offers a name-aware, type-only-aware impact computation.Template edges (a host component using a component, directive or pipe by selector or pipe name, see
collectTemplateEdgesin api) are opt-in and kept apart from the import edges: they never appear independencies/dependents, cycle detection or transitive dependents.Example