View Source 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 code
  • lib/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

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

defp deps do


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:

  1. 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
  1. 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]
  1. Include transitive dependencies ("dependencies of dependencies") using the lib_deps or mix_deps macros. (See "Chained Dependencies" below.)
deps do
  lib :some_included_lib do
    lib_deps [:utilities]

  mix :some_included_mix do
    mix_deps [:absinthe]


Chained Dependencies

mix uniform.eject follows chains of sub-dependencies completely.

Imagine this scenario.

  • uniform.exs has lib_deps: [:foo]
  • The Blueprint's deps says foo has lib_deps: [:bar]
  • The Blueprint's deps says bar has lib_deps: [:baz]

As a result, the ejected codebase will include lib/foo, lib/bar, and lib/baz.