I’d like to introduce WhyRecompile, a library provides utilities to work with Elixir files dependency graph. This aims to complement the mix xref graph
, helps you figure out questions like: Why file A and B recompiles when I edit file C?
Commands
Show all files with dependencies count
mix why_recompile list
-----------------------+-----------------------------+---------------------------------
File path | Number of recompile files | Number of MAYBE recompile files
-----------------------+-----------------------------+---------------------------------
lib/fixtures/D3.ex | 2 | 0
lib/fixtures/B4.ex | 2 | 0
lib/fixtures/B3.ex | 2 | 0
lib/fixtures/D2.ex | 1 | 0
lib/fixtures/B2.ex | 1 | 0
lib/fixtures/B1.ex | 1 | 0
lib/fixtures/A3.ex | 1 | 0
lib/fixtures/A2.ex | 1 | 0
-----------------------+-----------------------------+----------------------------------
Show all dependencies of a single file
You can increase the verbosity level for more detailed information: the dependency chain, the code snippets that cause such dependency, …
mix why_recompile show lib/fixtures/D3.ex
lib/fixtures/D1.ex
lib/fixtures/D2.ex
I hope that others find it useful! Please feel free to post any comments/feedback here, or issues on GitHub.