emezeske/lein-cljsbuild

Using a private ClojureScript build is unreasonably difficult

Open

#475 opened on Sep 6, 2017

View on GitHub
 (5 comments) (1 reaction) (0 assignees)Clojure (1,096 stars) (153 forks)batch import
Help Wanted

Description

(…and it's at least partly my fault! :-|)

The typical way to use a private/fork build of a library in leiningen is to:

  1. Put the artifact on e.g. clojars, under your own coordinates. For me, using a custom CLJS build for a time (waiting for a patch to be applied), that'd be [org.clojars.cemerick/clojurescript "whatever"].
  2. Replace the authoritative artifact's coordinates with those of the forked artifact.
  3. Add the authoritative groupId/artifactId to the global :exclusions in project.clj.

This does not work for ClojureScript when using lein-cljsbuild, because the latter adds a org.clojure/clojurescript dependency if it doesn't find one in :dependencies (via the cljsbuild subproject). This puts two revs of CLJS on the classpath (the default dep being quite old at this point), thus guaranteeing a bad time. (Whether Leiningen should be applying the top-level exclusions to the subproject's dependencies before actually launching the new process is a worthwhile question I'll be investigating separately.)

The only way to use a forked build of CLJS right now is to set up your own maven repository, to which you can deploy/host your private artifact using the org.clojure/clojurescript coordinates. (An example is here.) The top-level clojurescript dep then overrides cljsbuild's as always, it just happens to not be an authoritative build. This is a PITA.

A couple ways forward:

  1. If Leiningen's behaviour w.r.t. :exclusions not being applied to subproject dependencies is a bug, then we'll just wait for that to be fixed.
  2. If that behaviour is notabug, then we need to pick up the top-level :exclusions and explicitly add them to the cljsbuild dep that's mixed into the subproject.
  3. If for some reason (2) doesn't work, then maybe cljsbuild shouldn't have a default CLJS dependency. Doing this was on my list back in the day, but that automatic dependency was very useful when CLJS "releases" were less well understood, harder to track, and so on. Things are much different now, and I don't know that the default dependency is doing anyone any favors (i.e. how many CLJS beginners are using a years-old build of the compiler?).

This is just a placeholder for now. I'll return when I understand the :exclusions situation.

Contributor guide