Search code examples
clojuredependency-managementclojurescriptleiningenshadow-cljs

In a Clojure/ClojureScript project, what are the advantages of declaring dependencies on a `deps.edn` file instead of using `shadow-cljs.edn`?


I have been using Clojure, ClojureScript, lein, shadow-cljs, re-frame, reagent, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic web app project.

Currently, the project uses project.clj and shadow-cljs.edn to declare dependencies.

There is a discussion about changing things so that:

1 - We would start using a lein plug-in called lein-tools-deps

2 - Also, we would tweak shadow-cljs.edn file so that the dependencies would be removed and the file only indicate:

:dependencies true

3 - Finally, we would create a new deps.edn file holding all the dependencies.

It is not totally clear the advantages of this process.

I can see one: instead of declaring dependencies on shadow-cljs.edn and on project.clj they would be in a single file: deps.edn.

Is there another benefit of having dependency declaration via deps.edn instead of using shadow-cljs.edn and project.clj via :dependencies?

For instance, would this affect the use of Maven packages hosted on GitHub packages? Is deps.edn better for that?


Solution

  • deps.edn has the benefit that it supports direct git dependencies (ie. :git/url), as well as an easy mechanism for local dependencies (ie. :local/root). It is also more modern and becoming the "default".

    shadow-cljs.edn has no support for these features, project.clj has some via plugins or other mechanism (eg. checkouts).

    So, if you want those features it make sense to use deps.edn. However, depending on how complex your project is that might not be an easy switch.

    shadow-cljs ultimately doesn't care how you manage your dependencies, but if you move things out of shadow-cljs.edn you are taking "power" away from it. If managed via shadow-cljs.edn it tries to prevent certain mistakes (eg. dependency conflicts), it can't do that when running via deps.edn. So, you'll have to sort those out manually potentially. It may just work, really depends on your project.