Whenever mix phx.server is running, if I make any small changes to anywhere in the controller (even which is completely isolated), all the view files start compiling once again. So everytime I need to test something, it takes 30-40 seconds to load. I have disabled the views in live_reload configuration of dev.exs. But no luck. Is it normal or can we selectively disable these files from re-compiling again and again.
I sometimes have a similar problem when I create a a cyclical dependency across views. Try using mix xref graph --sink lib/<your_app>_web/views/<some_view>.ex --format dot && dot -Tpng xref_graph.dot -o xref_graph.png && open xref_graph.png
with one of your views to visually check for any cyclical deps.
Thanks for the response. I did this on couple of view files. But no luck.
What do you mean by “no luck” in this case?
Give Elixir master a go, there are significant improvements in this area: https://github.com/elixir-lang/elixir/blob/master/CHANGELOG.md#compilation-time-improvements. If you can’t, the linked topic mentions articles that I wrote about understanding sources of recompilations and using a script to automatically turn imports into aliases - hopefully you’ll find them helpful.
I mean, still every time it compiles the views as before.
What @idi527 posted was not supposed to fix your problem. It is giving you diagrams with which you can analyse which view depends on which and maybe untangle them a bit and thus reduce recompilation by yourself.
Sure got it.