Is there any portable format for elixir code? Other than the obvious tar.
For example, if I wanted to provide one or more modules to a client or fellow developers on ano
It depends on what you want to provide.
I will discuss three options below, all available through our build tool called Mix.
Hex packages source files. If you want to provide code for other developers to use in their projects, Hex is the best option because it knows how to fetch and resolve dependencies too. Call mix local.hex
to install it and then mix local
to see all available Hex tasks;
Escript allows you to bundle your whole project (including dependencies) into an executable that can be invoked from the command line. You need to have Erlang installed for escripts to work, you don't need to have Elixir installed though. Note an Escript cannot be used as a dependency by other projects.
Archives are basically a tar of compiled artifacts that the Erlang runtime knows how to load. Archives do not include dependencies and, in Elixir, they are used only as plugins for the Mix build tool. For example, Hex above is installed as an archive inside Mix.