Change in a live view template causes 42 files to be recompiled

:wave:

In a relatively small project (~243 files), changing a single line in a live view template .leex (colocated with an .ex file, so I guess it’s inserted in place of the render/1 function) causes 42 files (including the ones in app “contexts”) to be recompiled and prevents fast, iterative development. I’ve read that it could be due to phoenix router macros (but I’m I don’t know what to do with that info), what are other possible culprits, has anyone succeeded in reducing the number of files that get recompiled to 1, the template?

Is there maybe something like mix compile --trace to list the modules that are being compiled because of a change? And maybe there is some command to get the cause for why the files are being recompiled?

There’s MIX_DEBUG=1 mix compile, but it doesn’t show the files being recompiled. Could mix xref be used somehow?

Seems relevant:

Tried running fswatch _build -r | cat | grep .beam, and I see all live views being recompiled for a change in one of them …

The cause seems to be a sidebar.ex component that references many other liveviews.

Check out mix xref graph --label compile to check what modules depends on it during compilation.

1 Like

Strange thing that nothing is returned for --label compile, maybe there are some implicit dependencies.