I’ve got a project with several path dependencies. Some are phoenix apps, but this likely isn’t relevant.
I don’t fully understand the following behavior.
If I make a change in a file in a path dependency and run iex -S mix phx.server, the file is recompiled.
But if I make a change in a file in a path dependency while iex is already running, the file is not recompiled.
I know I can use r() on a particular module, but that’s not quite as convenient. Is there an easy way to get recompile to work on changed files in path dependencies?
As this is a top result on Google when searching for auto recompiling dependencies, I just wanted to leave a solution that doesn’t require a third party library (not sure if this was possible when the question was originally asked). This is for Phoenix apps running live_reload, if not, then exsync is still a good option.
You’ve got two projects my_app and my_dep. In my_app/mix.exs you’ve got:
defp deps do
{:my_dep, path: "../my_dep"}
..
end
In your config/dev.exs:
config :my_app, MyApp.Endpoint,
live_reload: [
patterns: [
# make sure you have patterns that work for either app, they should be relative
# to the root of a project, the same pattern can match both apps.
# So don't do '~r"../core_dep/priv"', that'll be ignored, do: '~r"priv"'
]
reloadable_apps: [:my_dep, :my_app]
Yeah I don’t think reloadable_apps existed at that time. But it is definitely a great to have available to you! Although a small note is that it doesn’t change the behavior of the IEx.Helpers.recompile command, instead you’ll have to be sure that you trigger Phoenix.CodeReloader (which is separate from phoenix_live_reload) by reloading a page in your Phoenix app.