如何重新编译Elixir项目并从iex内重新加载?

我目前正在Elixir-lang网站上通过OTP和混合教程学习Elixir,而且我无法找到如何从shell中重新编译和重新加载项目。

在Erlang中,我会做:all([load]),它会编译一个加载发生的任何更改。然而,在iex总是说:up_to_date,这是有道理的,因为Elixir使用组合来编译需求。

我在iex中找不到任何等价物。

最佳答案
您可以使用IEx.Helpers.recompile/0功能。

Recompiles the current Mix application.

This helper only works when IEx is started with a Mix project, for
example, iex -S mix. Before compiling the code, it will stop the
current application, and start it again afterwards. Stopping
applications are required so processes in the supervision tree won’t
crash when code is upgraded multiple times without going through the
proper hot-code swapping mechanism.

Changes to mix.exs or configuration files won’t be picked up by this
helper, only changes to sources. Restarting the shell and Mix is
required in such cases.

If you want to reload a single module, consider using r ModuleName
instead.

NOTE: This feature is experimental and may be removed in upcoming
releases.

https://github.com/elixir-lang/elixir/blob/v1.2.4/lib/iex/lib/iex/helpers.ex#L56-L93

转载注明原文:如何重新编译Elixir项目并从iex内重新加载? - 代码日志