DEV Community

Francesco
Francesco

Posted on

Clojure bites - dynamically add depencencies at runtime!

Full article

Overview

One pain point of REPL driven development is that even if it is possible to
change an application while it is running, if you want to experiment with a
new library it is need to add a new dependency to your project and restart the
REPL to use it, possibly breaking your flow.

Fortunately a new set of functions to alleviate this pain are in the works
and ready to be tested since Clojure 1.12.0-alpha2:

  • add-lib: Given a lib that is not yet on the repl classpath, make it available by downloading the library if necessary and adding it to the classloader.
  • add-libs: Given lib-coords, a map of lib to coord, will resolve all transitive deps for the libs together and add them to the repl classpath, unlike separate calls to add-lib.
  • sync-deps: Calls add-libs with any libs present in deps.edn but not yet present on the classpath.

Get the full content

This time the content of the post is be available on my site, especially to avoid editing it in too many places. Please let me know it is a deal breaker! If that is the case, I'll replicate it here.

Looking forward your feedback!

Top comments (0)