From b7c720fb3f7e03658608e3f3d5701dbd4f606dd4 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 14 Feb 2023 12:30:27 -0500 Subject: [PATCH] fix: make `depend_on_resources` more reliable --- lib/ash/api/info.ex | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ash/api/info.ex b/lib/ash/api/info.ex index 5659e770..5efa6c94 100644 --- a/lib/ash/api/info.ex +++ b/lib/ash/api/info.ex @@ -88,10 +88,18 @@ defmodule Ash.Api.Info do @spec depend_on_resources(Macro.t()) :: Macro.t() defmacro depend_on_resources(api) do quote do + Code.ensure_compiled!(unquote(api)) + if registry = Ash.Api.Info.registry(unquote(api)) do - @external_resource List.to_string(registry.module_info(:compile)[:source]) + Code.ensure_compiled!(registry) + # I guess I have to do this because the module name is dynamic? + # Still, seems pretty strange. This works, at least. + Kernel.LexicalTracker.remote_dispatch(__ENV__.lexical_tracker, unquote(api), :compile) + for entry <- Ash.Registry.Info.entries(registry) do - @external_resource List.to_string(entry.module_info(:compile)[:source]) + Code.ensure_compiled!(entry) + # same note as above + Kernel.LexicalTracker.remote_dispatch(__ENV__.lexical_tracker, entry, :compile) entry end else