Improving incremental compilation times
Hi there! I need to know what the best practices are when working with Ash resources and related files (calculations, preparations, etc), specifically around avoiding unnecessary dependencies and keeping compilation times low. Things to do, and what not to do.
I originally posted about this on the Elixir Forum (https://elixirforum.com/t/reducing-incremental-compilation-times-in-phoenix-ash-project/72113). The feedback there helped me better analyze my codebase and realize that I may be doing something wrong within Ash resources — and related files — myself, which has increased recompilation times (up to 10s).
My gut is telling me that what I'm doing here might be wrong:
I'm pretty new to this and had no idea about runtime/compilation dependencies until now, so before I continue with my project I’d better take some time to understand all of this to prevent it from continuing to happen, as it has already impacted my productivity.
Thanks in advance for your help.
Solution:Jump to solution
```elixir
defmodule Your.Resource.Changes.SendInvitationEmail do
use Ash.Resource.Change
def change(changeset, , ) ->...
3 Replies
Try putting that function in a change module instead of in-line
Solution
Alright, so the idea is that I shouldn't work directly within Ash resources, but in separate modules. Ash resources still take a while to recompile, but I shouldn't care much since the work I'm actively developing is in a separate module (and these modules compile quickly on every change)
Yes, this totally fixed my compilation times. I even had problems making changes to my controllers due to transitive dependencies to the modules I was calling within my Ash resources. Moving my logic to their own change modules totally fixed this. Thanks!