emezeske / lein-cljsbuild

Leiningen plugin to make ClojureScript development easy.
Other
1.1k stars 151 forks source link

Problem with lein-cljsbuild and lein-monolith #465

Closed chrisbetz closed 7 years ago

chrisbetz commented 7 years ago

Hi,

we're trying to use lein-monolith for building our Clojure/ClojureScript application. Unfortunately, lein-monolith does clash with lein-cljsbuild.

You can see this using the example repo from our fork.

Running

DEBUG=1 lein monolith each :in app-b do clean, cljsbuild once

from project root (monolith-path) is compiling clojurescript, but does not produce a result (as you can see in the output: there is no line like this Compiling "js/compiled/app.js" from ["src/cljs"].... (see below for full output).

Same is true if we're using hooks to run cljs compiler on regular leiningen tasks.

I also opened an issue on the lein-monolith repo, but I'm just not sure where the problem is located.

I would be very grateful for any hints on this. :)


Build from monolith project

~/Projects/lein-monolith/example   master  DEBUG=1 lein monolith each :in app-b do clean, cljsbuild once
Leiningen's classpath: :/usr/local/Cellar/leiningen/2.6.1/libexec/leiningen-2.6.1-standalone.jar
Applying task monolith to [each :in app-b do clean, cljsbuild once]
Elapsed: find-monolith => 0,065 ms
Found monolith project rooted at /Users/cb/Projects/lein-monolith/example
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/apps/app-a/project.clj
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/apps/app-b/project.clj
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/libs/lib-a/project.clj
Reading subproject definition from /Users/cb/Projects/lein-monolith/example/libs/lib-b/project.clj
Elapsed: read-subprojects! => 17,266 ms
Applying do clean, cljsbuild once to 1 subprojects...

Applying to example/app-b
Elapsed: init-subproject => 99,754 ms
Applying task do to [clean, cljsbuild once]
Applying task clean to []
Applying task cljsbuild to [once]
Compiling ClojureScript...
Elapsed: apply-task => 6217,942 ms
Completed example/app-b (1/1) in 0:06.320

SUCCESS: Applied do clean, cljsbuild once to 1 projects in 0:06.477

Build from sub-project

(not what I was trying to achieve, just for showing the actual correctness of our configuration)

 ~/Projects/lein-monolith/example   master ●  cd apps/app-b 
 cb@chris  ~/Projects/lein-monolith/example/apps/app-b   master ●  DEBUG=1 lein do clean, cljsbuild once
Leiningen's classpath: :/usr/local/Cellar/leiningen/2.6.1/libexec/leiningen-2.6.1-standalone.jar
Applying task do to [clean, cljsbuild once]
Applying task clean to []
Applying task cljsbuild to [once]
Compiling ClojureScript...
Compiling "js/compiled/app.js" from ["src/cljs"]...
Successfully compiled "js/compiled/app.js" in 15.613 seconds.
chrisbetz commented 7 years ago

BTW: lein version -> Leiningen 2.6.1 on Java 1.8.0_66 Java HotSpot(TM) 64-Bit Server VM

mneise commented 7 years ago

Thank you for the detailed description and for the example repo. Much appreciated 👍

I was able to reproduce your results. It seems that the build process is started (there is a Compiling ClojureScript... line in the output), but is terminated before producing a result. But that is just a first guess. I would need to do some further digging into how lein-monolith works.

chrisbetz commented 7 years ago

:) If you need any further help, info, anything, just let me know.

BTW: My guess is the "location" of the source folder is not found - as the build process is started, but doesn't really compile a thing. However, if started from the sub-project dir, everything is in place as cljsbuild expects it. Just my two cents.

mneise commented 7 years ago

Yes, you are right 👍 It looks for the source files in the directory where the build command was executed in, so for your example it looks in lein-monolith/example instead of lein-monolith/example/apps/app-b. (https://github.com/emezeske/lein-cljsbuild/blob/1.1.6/support/src/cljsbuild/compiler.clj#L139)

Seems like Leiningen passes a :root property in the project description, e.g. :root ~/Projects/lein-monolith/example/apps/app-b, which I can hopefully use for fixing this.

mneise commented 7 years ago

@chrisbetz Just pushed a first version of the fix to master and deployed it as 1.1.7-SNAPSHOT. cljsbuild finds the files now and builds the project, but outputs the result to the current working directory, so still need to fix this part 😉

chrisbetz commented 7 years ago

@mneise That's gorgeous. I'm happy to hear you found a possibility to fix things. Really looking forward. We're in the middle of a new release of our software, so I won't be able to check today or next monday, but I will try to look into 1.1.7-SNAPSHOT on tuesday to see if I can provide you with feedback on things (if you like). Really, really appreciating your work :) Thanx!

mneise commented 7 years ago

@chrisbetz I found a better fix for this.

Cljsbuild creates a new subprocess to run the compiler and the working directory for the subprocess wasn't set correctly, since cljsbuild didn't include the :root key in the project map. It should find the files now and also output the result to the right place.

Let me know if you run into any more problems 😉

thron7 commented 7 years ago

@mneise Hi Maria, which version contains your latest fix for this?

mneise commented 7 years ago

@thron7 You can try it out using 1.1.7-SNAPSHOT.