Unless you did something wrong, it should only recompile touched modules. But if you change a module that is used, included or required, you need to recompile all the modules that use it that way.
mix app.tree can help you to find out how compiletime dependencies.
I would be curious about what times you are seeing. mix compile --force in Ecto, which has 35k LOC over 68 files takes 5 seconds in my machine. And that is a full compilation. Elixirās compiler is incremental so most times you are waiting considerably less.
Just to clarify: mix compile does all of it for you, you donāt have to track anything. mix compile should also be fast enough, if the concern is the experience (quitting the shell and restarting it), then you can use file system watchers or invoke recompile in the shell directly.
That is about dependencies between applications. mix xref graph is the one that is about modules but you are generally not supposed to care.
EDIT: the clarifications are not for you @NobbZ just expanding your comments.
Iām new to Elixir as well, and I know some Erlangābut I also know Ruby pretty well, and I would describe Elixir as rubified Erlang, so Elixir has not been as difficult for me as Erlang was. Learning recursion in Erlang took a while.
In any case, I was very confused when I saw modules defined like this in Elixir:
defmodule My do
import A
require B
use C
...
..
end
The only one of import, require, and use that I could understand was import, which allows you to use the unqualified names of the functions defined in A, e.g. do_stuff() v A.do_stuff(). In other words, import just affects the namespacing of names.
On the other hand, require and use employ black magic to inject function definitions (and other definitions) into the module where the require or use statement appears. The black magic is accomplished via an Elixir feature called macros, which is an advanced topic. I got so frustrated not understanding what the heck was going on when I saw use, require, and import lumped together, that I skipped straight away to the macros section of my book. If you want to gain some understanding of require and use then you need to learn about macros. In any case, thatās where test() and assert() come from.
Just yesterday, I was trying to figure out what doctest KV does. Well, doctest is a macro and you are passing it the argument KV, and the macro performs some black magic which allows you to doā¦something related to testing!
doctest is a macro that searches a specified module for code examples and automatically generates test cases.
There is no black magic in require. All require does is to allow you to invoke a macro in some module. But if you only do require Foo and nothing more, nothing should happen.
You always have to require a module before you call a macro on it. That is requireās only purpose. In the example above, you used require. Note that import also requires it for you.
Yeah, by include I meant import. I tend to not use this one at all, I consider it polluting my namespace and Iām currently doing a lot of C, where we have #include preprocessor directiveā¦ Perhaps I was confused by that?
Still, in your āproofā of not needing to require or import modules, you used require, which I told you is a must have.