Fork me on GitHub

hi - I'm working on a clojurescript project and using boot-cljs. Just added a node server and trying to figure out how to separate out :source-paths between the 2 build tasks. my build.boot is currently like this:

  :source-paths #{"src"}
  :dependencies '[[org.clojure/clojure "1.9.0"]
                  [org.clojure/clojurescript "1.9.854"]
                  [adzerk/boot-cljs "2.1.4" :scope "test"]
                  [adzerk/boot-reload "0.5.2" :scope "test"]
                  [reagent "0.7.0" :exclusions [[cljsjs/react]
                  [secretary "1.2.3"]])

  '[adzerk.boot-cljs   :refer [cljs]]
  '[adzerk.boot-reload :refer [reload]])

(deftask client
  "Make client files"
    (cljs :source-map true
          :optimizations :none
          :compiler-options {:main "client.load"
                             :output-dir "public/js"
                             :output-to "public/js/app.js"
                             :npm-deps {:react "16.2.0"
                                        :react-dom "16.2.0"
                                        :create-react-class "^15.6.3"}
                             :install-deps true
                             :infer-externs true})

(deftask server
  "Make server files"
    (cljs :source-map true
          :optimizations :none
          :compiler-options {:main "server.main"
                             :target :nodejs
                             :npm-deps {:express "4.16.2"
                                        :react "16.2.0"
                                        :react-dom "16.2.0"
                                        :create-react-class "^15.6.3"}
                             :install-deps true
                             :infer-externs true})


Possibly using That could help as well with keeping deps separate (if that is something you'd like do to) You could maybe use it with either two aliases or even separate deps.edn files


any help would be appreciated


Hey @lalanikki what do you mean with separate source paths? would you like to have different values for :source-paths for the two builds?


you could call set-env! inside the task. That would prevent chaining them though, so the next step would be to run the task in a pod and set the sources there. That would mean having subfolders for the client and server code (if I understood correctly) (?)


If you scroll up I had a similar problem and candera kindly suggested a solution


@martinklepsch @nha I do seem to have the same situation - common, client, & server subdirectories where I want to exclude client from server file path and vice versa. Trying the solution @candera suggested with including in the task.


It’s sort of gross to have that sort of side effect, though. The more I think about it the less I’m thrilled with that. But not a Boot expert - maybe @micha or @alandipert or someone with more experience can comment. It’s certainly ought to be an option to have more than one build.boot in the same repo. But I guess if nothing else you can always restore the environment afterward.


what is the goal you wish to achieve by separating source paths?


the goal is to not have errors on client or server


Client-side entrypoint targets the browser and references document which you only find on client. When that runs when the server starts up, it causes a crash


Also, in loading the client entrypoint file it has references to server side libraries that cause errors


Nothing should reference files not used by build, no need to separate source-paths


^ that's what I would think. Maybe I have a different problem than I think


You don't have .cljs.edn files? That would break this because that case is horrible hack and breaks everything


@juhoteperi which case is the hack?


Without .cljs.edn file Boot-cljs will require all .cljs files in the fileset


Which is really bad idea, but required for legacy reasons in this case (boot-reload etc.)


yeah the .cljs.edn files are pretty important


Maybe this should be deprecated and instead the task could spit out a default “fill-in-the-blanks” cljs.edn file?


i believe that's what it does in the default case


it's just unable to figure out what exactly the entry point is, so it pulls in everything


Only way around this would be to hardcode boot-cljs to include boot-reload/cljs-repl/figwheel files in addition to main/require option, so it wouldn't have to load everything


The problem is that "addon" tools presume boot-cljs will automatically load their namespaces, if .cljs.edn can't be found


That is, only way if we keep supporting using boot-cljs without .cljs.edn, if we force everyone to use .cljs.edn files, that will remove lots of problems


When using Boot and Cider and am trying to compile a class with :gen-class in the namespace declaration, I’m getting a ClassCastException. Example:

(ns com.grzm.ex.boot.ds
   :name com.grzm.ex.boot.DS))

  (compile 'com.grzm.ex.boot.DS) ;; evaling this line


Exception details:

java.lang.ClassCastException: java.base/ cannot be cast to java.base/java.lang.String
clojure.lang.Compiler$CompilerException: java.lang.ClassCastException: java.base/ cannot be cast to java.base/java.lang.String, compiling:(com/grzm/ex/boot/DS.clj:1:1)


Works okay under a Lein repl. Any thoughts?