Tips to speed up compile times?
As my resources have grown, my compile times have gotten irritatingly long. Any tips for improving them?
Solution:Jump to solution
```elixir
defmodule Foo do
use Ash.Resource.Change
def change(changeset, opts, context) do...
11 Replies
fewer inline function changes can help
You can also try using
Spark.Dsl.Fragment to split up large resourcesWill give it a try 🫡
Are fragments supposed to help with compile times or is that more just for code organization?
Was originally designed for code organization but i think they may help w/ compile times
unverified 😄
What is the syntax for using a module instead of an inline function in an after_transaction hook?
I have my change module created with a
batch_change callback defined, but I can't figure out how to use it in place of an inline functionI don't think you need the
batch_changeSolution
Sorry I'm still not getting this ... What does this look like in my resource action then?
These ^^^ don't work
The first one returns a changeset when it's supposed to reutrn
{:ok, result}.
The second one is a module and it needs a function
Bah, sorry - have a good 4th!Did you figure it out?
Its just
change AfterCompleted w/ a module that implements the Ash.Resource.Change behaviourOHHHHH
Now I get it 😮
I do have a version working but it sucks
Basicaly just an external module with a change/3 function that takes goes like this:
But now I'm seeing we can compose all our changes in one Change module. just clicked
Ah, yeah so you can do it that way but generally speaking the "purest form" of it is
change SomeModule
that module can then implement various callbacks, add various hooks etc.I am levelling up on this independence day
This "pure" form also seems to be the only one that actually impacts compilation times. Haven't investigated fragments yet but when this Change module compiles it does not trigger the calling resource to compile