From 0227a11a578e04ac900843eedc47093fb3f04fc7 Mon Sep 17 00:00:00 2001 From: Enzo Date: Thu, 8 Aug 2024 13:26:06 +0200 Subject: [PATCH 1/4] xref: fix typo in doc --- lib/mix/lib/mix/tasks/xref.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mix/lib/mix/tasks/xref.ex b/lib/mix/lib/mix/tasks/xref.ex index acfcebdaa57..e4864c934ac 100644 --- a/lib/mix/lib/mix/tasks/xref.ex +++ b/lib/mix/lib/mix/tasks/xref.ex @@ -27,7 +27,7 @@ defmodule Mix.Tasks.Xref do touching one file in a project causes a large subset of the project to recompile. The most common cause of these problems are the so-called "compile-connected" files. Those are files you depend on at compile-time - (for example, by invoking its macro or using it in the body of amodule) + (for example, by invoking its macro or using it in the body of a module) which also have their own dependencies. Therefore, if your goal is to reduce recompilations, the first step is to run: From 91d24e9333e3191dac7282a7c7b73fbe022b12a2 Mon Sep 17 00:00:00 2001 From: Enzo Date: Thu, 8 Aug 2024 13:26:27 +0200 Subject: [PATCH 2/4] xref: do not limit compile-connected to runtime dependencies --- lib/mix/lib/mix/tasks/xref.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mix/lib/mix/tasks/xref.ex b/lib/mix/lib/mix/tasks/xref.ex index e4864c934ac..43f07f378d9 100644 --- a/lib/mix/lib/mix/tasks/xref.ex +++ b/lib/mix/lib/mix/tasks/xref.ex @@ -61,8 +61,8 @@ defmodule Mix.Tasks.Xref do because compile time dependencies are transitive. Having compile time dependencies is a common feature in Elixir projects. - However, the modules you depend on at compile-time must avoid runtime - dependencies within the same project. You can understand all of the + However, the modules you depend on at compile-time must avoid dependencies + to modules within the same project. You can understand all of the dependencies of a given file by running: $ mix xref trace lib/livebook_web.ex @@ -75,7 +75,7 @@ defmodule Mix.Tasks.Xref do Elixir tracks three types of dependencies between modules: compile, exports, and runtime. If a module has a compile time dependency on another module, the caller module has to be recompiled whenever the - callee changes (or any runtime dependency of the callee changes). + callee changes (or any dependency of the callee changes). Let's see an example: # lib/a.ex From 38606ba855b35e020e216c9a750cc8dc9ecb8ca6 Mon Sep 17 00:00:00 2001 From: Enzo Date: Fri, 25 Oct 2024 15:40:34 +0200 Subject: [PATCH 3/4] add links to get more details about compilation and dependencies --- lib/elixir/pages/mix-and-otp/introduction-to-mix.md | 2 ++ lib/mix/lib/mix/tasks/compile.elixir.ex | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/elixir/pages/mix-and-otp/introduction-to-mix.md b/lib/elixir/pages/mix-and-otp/introduction-to-mix.md index c326154e8d2..8bc83d47d59 100644 --- a/lib/elixir/pages/mix-and-otp/introduction-to-mix.md +++ b/lib/elixir/pages/mix-and-otp/introduction-to-mix.md @@ -176,6 +176,8 @@ iex> recompile() If anything had to be compiled, you see some informative text, and get the `:ok` atom back, otherwise the function is silent, and returns `:noop`. +To go further, check out [`mix compile.elixir`](https://hexdocs.pm/mix/Mix.Tasks.Compile.Elixir.html) documentation. + ## Running tests Mix also generated the appropriate structure for running our project tests. Mix projects usually follow the convention of having a `_test.exs` file in the `test` directory for each file in the `lib` directory. For this reason, we can already find a `test/kv_test.exs` corresponding to our `lib/kv.ex` file. It doesn't do much at this point: diff --git a/lib/mix/lib/mix/tasks/compile.elixir.ex b/lib/mix/lib/mix/tasks/compile.elixir.ex index 0f4ce2fdb42..bf1572dba2f 100644 --- a/lib/mix/lib/mix/tasks/compile.elixir.ex +++ b/lib/mix/lib/mix/tasks/compile.elixir.ex @@ -10,7 +10,9 @@ defmodule Mix.Tasks.Compile.Elixir do Elixir is smart enough to recompile only files that have changed and their dependencies. This means if `lib/a.ex` is invoking a function defined over `lib/b.ex` at compile time, whenever - `lib/b.ex` changes, `lib/a.ex` is also recompiled. + `lib/b.ex` changes, `lib/a.ex` is also recompiled. More details + about dependencies between files can be found in the documentation + of [`mix xref`](`Mix.Tasks.Xref`). Note Elixir considers a file as changed if its source file has changed on disk since the last compilation AND its contents are From f24e69a27b38e7b2f36cdbd59ed0cde7ee7e6be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 30 Oct 2024 08:52:54 +0100 Subject: [PATCH 4/4] Update lib/elixir/pages/mix-and-otp/introduction-to-mix.md --- lib/elixir/pages/mix-and-otp/introduction-to-mix.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/elixir/pages/mix-and-otp/introduction-to-mix.md b/lib/elixir/pages/mix-and-otp/introduction-to-mix.md index 8bc83d47d59..c326154e8d2 100644 --- a/lib/elixir/pages/mix-and-otp/introduction-to-mix.md +++ b/lib/elixir/pages/mix-and-otp/introduction-to-mix.md @@ -176,8 +176,6 @@ iex> recompile() If anything had to be compiled, you see some informative text, and get the `:ok` atom back, otherwise the function is silent, and returns `:noop`. -To go further, check out [`mix compile.elixir`](https://hexdocs.pm/mix/Mix.Tasks.Compile.Elixir.html) documentation. - ## Running tests Mix also generated the appropriate structure for running our project tests. Mix projects usually follow the convention of having a `_test.exs` file in the `test` directory for each file in the `lib` directory. For this reason, we can already find a `test/kv_test.exs` corresponding to our `lib/kv.ex` file. It doesn't do much at this point: