I have a phoenix project on Elixir 1.4.2, which loads a package with path: like following:
defp deps do
[
{:a_package, path: "../../a_package", runtime: false},
]
The package has several files. When I modify a file in the package, is there any way to make the phoenix project reload it, not only with reloading the phoenix but also reloads it automatically?
Dependencies are expected to be static, so that is definitely not a usual use-case. ^.^
You ‘might’ be able to be changing the watched paths for the phoenix reloader to that path as well, but that reloader only does the equivalent of calling mix compile I think, which will not recompile a dependency automatically either.
You could make it an umbrella project and make both parts of the umbrella?
Even if you were able to change the pathes which are watched, only mix compile were called, but you need to call mix do deps.update $yourdep, deps.compile, compile. And even when you do the latter, I’m not even sure if that fresh compiled modules are reloaded then, or that of the app only. After compilation they live in different areas of your _build folder.
A dependency shouldn’t change that often, and if you change your dep more often than the core, then your dependency is propably not a dep, but your application in which case you should either integrate it or make it an umbrella.
This is old, but I am developing a package and it’s so annoying that I have to restart the Phoenix server each time I make a change in the package code.
I am having an hard time believing that when Jose, Chris and others from the core team have to develop a package, that they have to keep restarting the server to see the code changes applied.
So I am curious to know what is the workflow that package developers use in order to avoid this big annoyance?
It seems to me that what you mention may be useful for developing the package in isolation, but I am developing it while using it for real in my application, that already has a running server.
I’ve made the umbrella app and then create a symlink from package directory to umbrella apps: ln -s ~/Dev/my_package ~/Dev/my_demo_umbrella/apps/my_package
With this setup code reloading works somehow even without dependency in other apps mixfiles.
Almost 3 years later but @focused or @Exadra37 did you find a better solution for this?
What we are doing now is creating a symlink of our package directory in deps ln -s ~/dev/my_package ~/dev/my_app/deps/my_package and then setup the path dependency to the symlink like {:my_package, path: "deps/my_package"} and then in mix file we added it as an elixir path for dev only defp elixirc_paths(:dev), do: ["lib", "deps/my_package/lib"] with this we are getting the deps changes in elixir files reflected in our app without restarting the server.
If not mistaken I just end-up to develop the package inside lib folder, but I think my first approach was to add the package paths to the reload config.
If you add the app name to reloadable_apps in your Endpoint config then the path dependency will be reloaded when you reload the page: Phoenix.CodeReloader — Phoenix v1.6.16