Fork me on GitHub
#boot
<
2018-03-30
>
borkdude11:03:44

should using the new aot-cache in cljs also work properly with boot?

michal12:03:50

hey there, just wondering how do you guys create an uberjar with clojurescript sources compiled? I have a simple task (comp (build) (aot) (uber) (jar)) where "build" is a (comp (cljs) (sass)). both "src/clj" and "src/cljs" are listed in :source-paths. Now, not only aot task tries to compile cljs files (most likely because they're mentioned as sources), but also main.out directory with whole bunch of intermediate javascript files is unnecessarily added to uberjar increasing its size.

michal12:03:14

in general everytime I try to do something with clojurescript I have again to scratch my head whether clojurescript sources should be mentioned in :source-paths. if so, that implicates some strange results like the one I described.

michal12:03:39

also, is there any way to differentiate (based on some pattern matching) which other tasks reload task should trigger? eg. when cljs are changed I'd like to trigger (cljs) task, but if scss are altered I'd like to trigger (scss) one. as for now, no matter which file is changed both tasks are unnecessarily triggered.

borkdude13:03:58

@michal fwiw, this is what we use:

:source-paths #{"test" "src-cljs"}

(deftask build-cljs []
  (set-env! :source-paths #(conj % "src-cljs-prod"))
  (cljs :optimizations :advanced
        :source-map true
        :compiler-options {:foreign-libs foreign-libs}))

(deftask build-less []
  (less :source-map false :compression true :inline-javascript true))

(deftask build []
  (comp (include-assets) (build-cljs) (build-less) (aot) (pom) (uber)
        (jar :file "app-standalone.jar")
        (sift :include #{#"app-.*\.jar"}) (target)))

borkdude13:03:48

I extracted the uberjar to see what’s in it and in our case it also includes the .cljs files. Is that bad? I don’t know. Let me think about it.

michal13:03:31

@borkdude thanks, that looks very similar to what I have and I guess you also have a entire main.out (or similar) with all the cljs-es in your uberjar 🙂

michal13:03:52

well, I don't think it's horribly bad, but that makes uberjar much bigger

michal13:03:11

in my simple project it's 5MB of unnecessary sources

borkdude13:03:58

hmm, yes, I can retrieve our source by going to app.out/…/app.cljs… hmm, good point

michal13:03:21

you're welcome 🙂

michal13:03:35

I think it shouldn't be hard simply to remove these sources before uberjar-ing, but I didn't figure it out yet

borkdude13:03:13

Maybe sift can be used for this

borkdude13:03:20

let me know if you find out.. 🙂

borkdude14:03:07

@michal this seems to work: (sift :invert true :include #{#“app\.out”})

borkdude14:03:02

it’s a bit too strict

borkdude14:03:07

my app.js is also gone 😉

michal14:03:33

@borkdude you're going exactly the way I went hour ago 🙂

michal14:03:08

it's really hard to sift-invert and include necessary things into uberjar

borkdude14:03:15

yeah, why is this so hard

michal14:03:27

I'm slowly starting looking at shadow-cljs to handle clojurescript part of app. seems like it might be better (and faster) solution than boot's cljs & reload tasks. the only problem is that it doesn't play nice with boot's immutable filesets philosophy.

borkdude14:03:07

you might also want to look at clj + cljs.main

michal14:03:28

oh, any details?

borkdude14:03:08

for newer projects I want to try that

michal14:03:15

thanks, will look at it too.

borkdude14:03:28

(sorry boot)

borkdude14:03:30

@michal it works now with sift

borkdude14:03:46

@michal silly mistake, I didn’t use comp so it was executed at the wrong time

michal14:03:14

great, I will check it out. I'm looking now at juxt's edge and I'm amazed how gathered all the cool stuff into one place 🙂

dominicm18:03:36

Come bother us in #juxt iif you want any help

dominicm18:03:20

Originally I used shadow for krei (used in edge), but our own projects needed figwheel. Happy to have both though!

borkdude18:03:03

@michal Turns out we do need the app.out folder in deployment because our monitoring system does source mapping and shows part of the source where an error occurred 🙂. It’s protected by login though.