When to compile in Elixir only
When would it be appropriate to specify the dependency only in deps
mine mix.exs
, rather than as a runtime dependency in applications
?
I thought applications
these are real applications that need to be run before running my own application, but I ran into a problem where I exrm
didn't put the library Jazz
(which I think only contains pure functions) in the release until I included :jazz
in applications
.
source to share
An OTP application is more like a component - a lot of modules and functions that can (but do not have to) start some processes. If the OTP application does not launch its own watch tree, it is called a library application. Anyway, if you are using some of the libs functions at runtime, you need to specify it as runtime debug.
In contrast, a compile-time dependency ensures that third-party code is fetched and available locally (on your dev / build machine). This is useful if third-party code does its magic outside of the runtime. An example would be my own ExActor or the pure Erlang meck mocking library. In the first case, ExActor does its magic at compile time, and in the second case, you only need a mocking library during tests.
source to share