Skip to content

Commit

Permalink
Load modules for mix recompile all-at-once (#14006)
Browse files Browse the repository at this point in the history
  • Loading branch information
naserca authored Dec 10, 2024
1 parent 051bffa commit 480945a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/mix/lib/mix/compilers/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,26 @@ defmodule Mix.Compilers.Elixir do
Map.has_key?(stale_modules, module) ->
{[module | modules_to_recompile], modules_to_mix_check}

recompile? and Code.ensure_loaded?(module) and
function_exported?(module, :__mix_recompile__?, 0) ->
recompile? ->
{modules_to_recompile, [module | modules_to_mix_check]}

true ->
{modules_to_recompile, modules_to_mix_check}
end
end

_ = Code.ensure_all_loaded(modules_to_mix_check)

modules_to_recompile =
modules_to_recompile ++
for {:ok, {module, true}} <-
Task.async_stream(modules_to_mix_check, &{&1, &1.__mix_recompile__?()},
Task.async_stream(
modules_to_mix_check,
fn module ->
{module,
function_exported?(module, :__mix_recompile__?, 0) and
module.__mix_recompile__?()}
end,
ordered: false,
timeout: :infinity
) do
Expand Down

0 comments on commit 480945a

Please sign in to comment.