Compatibility macros for Elixir v1.5+ child specifications
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

child-spec-compat Version Documentation

As of Elixir v1.5 there has been a new pattern recommended for child specifications, rather than those which exist in Supervisor.Spec (which is now deprecated). This library provides a simple shim to compile the newer syntax on older Elixir versions with the same behaviour, to remove dependencies on the deprecated module. All of this happens at compile time to remove any overhead when you're on a supported version.

If you run your code purely on Elixir > v1.5, you should use Supervisor.child_spec/2 directly; this module is aimed at library developers who provide support for older Elixir versions and cannot migrate exclusively to the new syntax.


This library is available on Hex. You can install the package via:

def deps do
  [{:child_spec_compat, "~> 1.0"}]


The intent of this module is to operate in the same way as Supervisor.child_spec/2, so please see the official documentation. The only difference is that you need to call ChildSpecCompat.child_spec/2 instead. As it's a macro, you need to either require or import the module in advance of using it. If examples are needed, please see the tests in this repo.