improvement: improve compile times with 🪄

This commit is contained in:
Zach Daniel 2023-03-23 22:39:56 -04:00
parent de550e7bac
commit 5bfc1aeb0c
2 changed files with 11 additions and 4 deletions

View file

@ -189,7 +189,7 @@ defmodule Ash.Resource.Dsl do
end end
""" """
], ],
modules: [:destination], no_depend_modules: [:destination],
target: Ash.Resource.Relationships.HasOne, target: Ash.Resource.Relationships.HasOne,
schema: Ash.Resource.Relationships.HasOne.opt_schema(), schema: Ash.Resource.Relationships.HasOne.opt_schema(),
args: [:name, :destination] args: [:name, :destination]
@ -212,7 +212,7 @@ defmodule Ash.Resource.Dsl do
""" """
], ],
target: Ash.Resource.Relationships.HasMany, target: Ash.Resource.Relationships.HasMany,
modules: [:destination], no_depend_modules: [:destination],
schema: Ash.Resource.Relationships.HasMany.opt_schema(), schema: Ash.Resource.Relationships.HasMany.opt_schema(),
args: [:name, :destination] args: [:name, :destination]
} }
@ -242,7 +242,7 @@ defmodule Ash.Resource.Dsl do
belongs_to :word, Word, primary_key?: true, allow_nil?: false belongs_to :word, Word, primary_key?: true, allow_nil?: false
""" """
], ],
modules: [:destination, :through], no_depend_modules: [:destination, :through],
target: Ash.Resource.Relationships.ManyToMany, target: Ash.Resource.Relationships.ManyToMany,
schema: Ash.Resource.Relationships.ManyToMany.opt_schema(), schema: Ash.Resource.Relationships.ManyToMany.opt_schema(),
transform: {Ash.Resource.Relationships.ManyToMany, :transform, []}, transform: {Ash.Resource.Relationships.ManyToMany, :transform, []},
@ -267,7 +267,7 @@ defmodule Ash.Resource.Dsl do
end end
""" """
], ],
modules: [:destination], no_depend_modules: [:destination],
target: Ash.Resource.Relationships.BelongsTo, target: Ash.Resource.Relationships.BelongsTo,
schema: Ash.Resource.Relationships.BelongsTo.opt_schema(), schema: Ash.Resource.Relationships.BelongsTo.opt_schema(),
args: [:name, :destination] args: [:name, :destination]

View file

@ -108,6 +108,13 @@ defmodule Ash.Schema do
alias Ash.Query.Aggregate alias Ash.Query.Aggregate
use Ecto.Schema use Ecto.Schema
@primary_key false @primary_key false
after_compile = @after_compile -- [{__MODULE__, :__after_compile__}]
Module.delete_attribute(__MODULE__, :after_compile)
Module.register_attribute(__MODULE__, :after_compile, accumulate: true)
for compile_hook <- after_compile do
@after_compile compile_hook
end
schema Ash.DataLayer.source(__MODULE__) do schema Ash.DataLayer.source(__MODULE__) do
for attribute <- Ash.Resource.Info.attributes(__MODULE__), for attribute <- Ash.Resource.Info.attributes(__MODULE__),