View Source Dependencies
lib-dependencies
Lib Dependencies
Sharing code between apps is central to the design of Uniform. Lib Dependencies are the main code-sharing mechanism of Uniform.
A Lib Dependency is a code library in a subdirectory of the Base Project's
lib directory. For example:
lib/auth, containing shared authentication codelib/ui, containing shared user interface code
Lib Dependencies are great for sharing non-public code between Ejectable Apps with less ceremony than other mechanisms like private Hex packages.
You can easily add or remove Lib Dependencies from ejected codebases as needed.
mix-dependencies
Mix Dependencies
When an app is ejected, Uniform copies over the Base Project's mix.exs and
mix.lock, but removes unrequired mix deps. (See Adding Dependencies to an
App.)
To modify deps properly, Uniform requires a defp deps function in
mix.exs. This is the standard structure generated by mix new and mix phx.new.
defp deps do
[
...
]
end
adding-dependencies-to-an-app
Adding Dependencies to an App
By default, all dependencies are excluded from an app's ejected codebase. When you eject an app:
- Excluded Lib Dependencies will be missing from
lib - Excluded Mix Dependencies will be missing from
mix.exs
There are three ways to include a dependency:
- Include a dependency in all Ejectable Apps by placing the it in the always section of your Blueprint.
deps do
always do
lib :utilities
mix :absinthe
end
end- Include a dependency in a single Ejectable App by saying so in uniform.exs.
# lib/my_app/uniform.exs
[
lib_deps: [:utilities],
mix_deps: [:absinthe]
]- Include transitive dependencies ("dependencies of dependencies") using the
lib_depsormix_depsmacros. (See "Chained Dependencies" below.)
deps do
lib :some_included_lib do
lib_deps [:utilities]
end
mix :some_included_mix do
mix_deps [:absinthe]
end
end
chained-dependencies
Chained Dependencies
mix uniform.eject follows chains of sub-dependencies completely.
Imagine this scenario.
uniform.exshaslib_deps: [:foo]- The Blueprint's
depssaysfoohaslib_deps: [:bar] - The Blueprint's
depssaysbarhaslib_deps: [:baz]
As a result, the ejected codebase will include lib/foo, lib/bar, and
lib/baz.