Modifying a controller recompiles my router and all UI layer

I finally solved my problem :partying_face:
Touching a view now recompiles only 1 file, and touching a controller recompiles 2 files (the controller and the endpoint) instead of 208 … (went from 30sec to 2sec)

What did I do?

  • watched this video twice :wink:
  • ran a gazillion times mix xref graph --source lib/../my_controller.ex and xref graph --sink lib/../router.ex
  • also ran fswatch _build -r | cat | grep .beam to actually see what files are being recompiled
  • aliased RouteHelpers instead of importing them
  • removed any hard reference to LayoutView or Router in any of my plugs. I had to workaround this problem by using Module.concat["MyApp.Router.Helpers"] in my navigation plugs
  • had a weird dependency issue related to Coherence library when coherence_routes were inlined in my app main scope instead of its own dedicated scope
  • the last one still seems weird to me, but I also had to rewrite any defdelegate calls from views to other views into a classic function call

Hope it will help someone, and if you have any comment about my post, feel free!

8 Likes