Fork me on GitHub
#figwheel-main
<
2021-03-19
>
Janne Sauvala20:03:50

I have a fullstack CLJ/CLJS app and I try to compile a production bundle from the CLJS part. I’m running alias clj -M:build-fig-prd where

:build-fig-prd {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "prd"]
                  :extra-deps {com.bhauman/figwheel-main {:mvn/version "0.2.12"}}}
It seems that one of my Java dependencies (used in server side) in deps.edn somehow doesn’t work with the advanced compilation since it fails with:
[Figwheel] Compiling build prd to "dist/main_bundle.js"
[Figwheel] Failed to compile build prd in 4.339 seconds.
[Figwheel:WARNING] Compile Exception: com.google.common.collect.Streams  
[Figwheel:SEVERE] com/google/common/collect/Streams
Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:606).
com.google.common.collect.Streams
If I comment out my Java dependency google-cloud-texttospeech the build succeeds.
:deps {org.clojure/clojure {:mvn/version "1.10.2"}
        org.clojure/clojurescript {:mvn/version "1.10.773"}
        ...
        com.google.cloud/google-cloud-texttospeech {:mvn/version "1.3.0"}
I’m wondering do I need to change my project setup somehow to prevent my server side dependencies to create problems on frontend build or is there something else I can do here?

flowthing04:03:27

A very late reply, so you probably already came up with a solution, but that looks like a Guava dependency conflict. ClojureScript depends on Guava, and, presumably, so does google-cloud-texttospeech. Perhaps setting an explicit dependency on the Guava version that ClojureScript requires would fix the issue. If you're unlucky, that might break google-cloud-texttospeech, of course, in which case... :man-shrugging::skin-tone-2:

flowthing05:03:59

Generally, though, it's better to have ClojureScript-only dependencies in a separate profile (e.g. :dev) so that they don't end up in the uberjar you're possibly making. After all, you likely only need the compiled JavaScript artifact in there.

Janne Sauvala11:03:14

Thanks Eero for replying. I also finally figured out that it is better to have separate profiles for the front end and backend codes. Good point that I should also separate the dev deps on front end side so only the compiled JS artifact would go to the uberjar 👍:skin-tone-2: