I’m currently trying to improve the compilation times of a project I’m working on, by removing dependencies between modules. One hotspot is caused by the user socket or rather the channel/3
-macro.
The socket looks something like this
defmodule MyAppWeb.UserSocket do
use Phoenix.Socket
use Absinthe.Phoenix.Socket, schema: MyAppWeb.Graphql.Schema
channel "my_topic:*", MyAppWeb.Channel.MyTopic
end
And calling mix xref trace
reveals the following compile dependencies.
$ mix xref trace lib/my_project/channels/user_socket.ex
lib/my_project/shared/channels/user_socket.ex:3: alias MyProject.Graphql.Schema (compile)
lib/my_project/shared/channels/user_socket.ex:9: alias MyProjectWeb (compile)
I’m looking at the implementation of channel/3
, but I don’t see a reason why there is a compile dependency. Does someone know why and how to avoid it?