Optimizing Re-compilation in Elixir Projects

80
clicks
Optimizing Re-compilation in Elixir Projects
In this article, Wojtek Mach tackles the issue of slow re-compilation times in Elixir projects. The main focus is on understanding how Elixir tracks dependencies between files, distinguishing between initial compilation and re-compilation, which can become a major source of frustration if not managed correctly. The article outlines the different types of dependencies—runtime, compile-time, and export dependencies—and how changes to these can trigger re-compilations. It also provides practical diagnostic steps using tools like `mix xref graph` to identify problematic dependencies and offers solutions such as refactoring imports to aliases and adjusting Plug settings. Specific tips for Phoenix projects are shared, including changes to router imports and Plug initialization settings.

© HashMerge 2024