Understanding how LiveView removed module references in attr as a compile time dependency

I’m looking into how to reduce some compile time dependencies and stumbled across how LiveView removed its compile time dependency on Modules referred to in attrs. So something like the following is no longer a compile time dependency.

attr :user, User, required: true
  1. How does expanding an alias prevent the compile time dependency?
  2. Does that mean if it’s not an alias it will still be a compile time dependency?
  3. What does Macro.expand(alias, %{env | function: {:__attr__, 3}})in layman terms do?

I couldn’t find/understand too much in the Macro documentation so I’m a little confused when it comes to Elixir AST details.

Thanks in advance for any help!

1 Like