Requires is one of the interactive graphs Understand can draw of your code — call trees, dependencies, control flow, and more.
Requires
Languages: Rust, WebTargets: Files, Generics
Variants: Classic, Cluster, Compare, Relationship, Simplified
Show what a selected JavaScript file or Rust generic parameter, associated type, or trait requires, directly or indirectly.
For a selected JavaScript file, this shows an edge to each module it requires, then recurses into each of those files’ own requires, building a multi-level tree. For a Rust generic parameter, associated type, or trait, this shows an edge to each trait it requires as a bound; since a trait can itself require another trait as a supertrait bound, this can continue to recurse.
Rooted at app.js below, the graph shows app.js requiring api.js and auth.js. Both api.js and auth.js require database.js, which itself requires logger.js and config.js. logger.js and config.js each require constants.js, which requires nothing further. The inverse graph, Required By, shows the reverse relationship — everything that requires the selected file or Rust entity, directly or indirectly.
See the following code and corresponding graph
// app.js
const { getUsers } = require('./api');
const { login } = require('./auth');
// api.js
const { connect, query } = require('./database');
// auth.js
const { connect, query } = require('./database');
// database.js
const { log, error } = require('./logger');
const { config } = require('./config');
// config.js
const { API_URL, MAX_RETRIES } = require('./constants');
// logger.js
const { TIMEOUT_MS } = require('./constants');
// constants.js
Requires - Classic
The Classic variant is similar to the Simplified variant, showing all relationships in a simple tree, but it uses a custom layout algorithm instead of Graphviz.
Requires - Cluster
The Cluster variant groups entities by their containing class/file/architecture.
Requires - Compare
The Compare variant shows how the graph has changed relative to the project's comparison database.
Requires - Relationship
The Relationship variant filters the graph to only paths connecting the two entities.
Requires - Simplified
The Simplified variant shows all relationships in a simple tree (no clusters)