CodeGraph/docs
Section 4.4

Dependency Analysis (Downstream)

Discovers the complete transitive downstream dependency closure of a file or symbol by walking outgoing edges forward.

Source: server/src/analytics/dependency/DependencyAnalyzer.ts

Downstream Reachability Semantics

The DependencyAnalyzer is the forward mirror of the ImpactAnalyzer. It answers:"What does this function or file depend on, directly or transitively, to compile and run?"

server/src/analytics/dependency/DependencyAnalyzer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export class DependencyAnalyzer { constructor(private readonly traversal: GraphTraversal) {} analyze(sourceNodeId: string, options: DependencyAnalysisOptions = {}): DependencyAnalysisResult { const traversalResult = this.traversal.traverse(sourceNodeId, { direction: "outgoing", relationshipKinds: [ "calls", "imports", "extends", "implements", "instantiates", ], maxDepth: options.maxDepth, }); return { sourceNodeId, dependencyNodeIds: traversalResult.nodes, depthByNode: traversalResult.depthByNode, }; } }

Primary Use Cases

  • Test Mocking Isolation: Identify all depth 1 dependencies that must be mocked to test a symbol in isolation.
  • Bundle Splitting: Evaluate the full closure size pulled into client bundles when importing a given component.