Picture Guide: The Shapes Dependency Graphs Take
Draw the dependencies of almost any application and a few shapes repeat. Recognising them helps library authors predict the bug reports they will receive, because each shape breaks in a characteristic way. Below are five shapes, each described as a figure with a caption and a note on what you, as the author of one node in the graph, can do about it.
Shape 1: the diamond
Figure: an application at the top depends on Library A and Library B. Both A and B depend on Library D. Four nodes, four arrows, a diamond outline.
Caption. The classic conflict. If A needs D version 1 and B needs D version 2, something has to give. In pip the install fails; in Go, the two majors are different module paths and coexist; in npm, two copies may be installed side by side, which is fine for a pure utility and broken for anything holding shared state.
What D's author can do: avoid unnecessary major releases, and keep old majors working long enough for both A and B to move.
Shape 2: the long chain
Figure: a vertical line of six nodes, each depending on the one below.
Caption. A fix at the bottom has to travel up through every intermediate package before the application sees it, if those packages pin narrowly. Wide, honest version ranges let fixes flow through without every maintainer in the chain cutting a release.
Shape 3: the plugin star
Figure: a central framework node with many small plugin nodes around it. Dotted lines, not solid arrows, connect the plugins to the centre.
Caption. Plugins should not bring their own copy of the framework. The dotted lines represent peer dependencies: the plugin states which framework versions it works with, and the application supplies the single copy. Our peer dependency guide covers how to declare them.
{
"name": "framework-plugin-example",
"peerDependencies": { "framework-example": "^4.0.0 || ^5.0.0" },
"devDependencies": { "framework-example": "^5.2.0" }
}
Shape 4: the hub package
Figure: one small node with dozens of incoming arrows from all over the graph.
Caption. A tiny utility that almost everything uses. Any change to it touches a huge number of installs, and it is an attractive target for account takeover. If you maintain a hub, the security basics on our key facts page matter more to you than to almost anyone.
Shape 5: the hidden cycle
Figure: two packages, each with an arrow pointing to the other, drawn in red.
Caption. Some package managers tolerate cycles, but they complicate builds, make module initialisation order unpredictable in JavaScript, and are not permitted between Go packages at all (imports cannot be cyclic). They usually signal that two packages should be merged or that shared code should move into a third.
Reading your own graph
| Ecosystem | Command to view the tree |
|---|---|
| npm | npm ls --all or npm explain <name> |
| pip | pip show <name> for direct requirements; third-party tools draw full trees |
| Go | go mod graph and go mod why <module> |
| Cargo | cargo tree, with -d to show duplicates |
Sketch the result by hand once. Seeing your own package's position, as a hub, a link in a chain or a plugin, tells you which of these shapes your users are most likely to hit.