Volt.DepGraph (Volt v0.12.0)

Copy Markdown View Source

ETS-backed module dependency graph.

Tracks which files import which specifiers and which import.meta.glob() patterns they own, enabling reverse lookups for HMR propagation — "what depends on this file?"

Summary

Functions

Clear the entire graph.

Create the dependency graph ETS table. Called once from Application.start/2.

Find all files that import the given specifier.

Find all files that import a specifier matching the given predicate.

Find all files with an import.meta.glob() pattern matching path.

Get the imports for a file path.

Remove a file from the graph.

Update the imports for a file path.

Update imports and glob patterns from source and compiled code.

Functions

clear()

@spec clear() :: :ok

Clear the entire graph.

create_table()

@spec create_table() :: :ok

Create the dependency graph ETS table. Called once from Application.start/2.

dependents(specifier)

@spec dependents(String.t()) :: [String.t()]

Find all files that import the given specifier.

Used by HMR to propagate changes upward through the dependency tree.

dependents_matching(predicate)

@spec dependents_matching((String.t() -> boolean())) :: [String.t()]

Find all files that import a specifier matching the given predicate.

The predicate receives each import specifier and should return true if it matches the file being searched for.

glob_dependents(path)

@spec glob_dependents(String.t()) :: [String.t()]

Find all files with an import.meta.glob() pattern matching path.

imports_of(path)

@spec imports_of(String.t()) :: [String.t()]

Get the imports for a file path.

remove(path)

@spec remove(String.t()) :: :ok

Remove a file from the graph.

update(path, imports, globs \\ [])

@spec update(String.t(), [String.t()], [String.t()]) :: :ok

Update the imports for a file path.

update_from_source(path, source, compiled_code)

@spec update_from_source(String.t(), String.t(), String.t()) :: :ok

Update imports and glob patterns from source and compiled code.