Fork me on GitHub

How do I update new dependencies in shadow-cljs?


I added a new dependency in shadow-cljs.edn, (by the way I’m using intellij + cursive) and re-ran shadow-cljs watch app. But my cljs file still cannot find required libraries in the namespace.


I’ve done pom.xml-> download sources as well.


I just restart shadow-cljs



shadow-cljs watch app 


if its already running no, you need to restart it fully. shadow-cljs stop should shut it down completely


also depends on how you have configured shadow-cljs.edn. if you have a :deps key in there then dependencies need to be added in deps.edn. if there is a :lein then it would be project.clj.


Thanks! I ran

shadow-cljs pom
and re-imported the project in ide, which worked out.


ah, thought you meant shadow-cljs didn't find dependencies. yeah shadow-cljs pom to make the dependencies visible for Cursive

👍 3
🙏 3
Michaël Salihi09:06:51

Hi! I'm interested in how to manage the versions of the JS bundle. I have read the part of the documentation and knowing that my html is generated by hiccup, I am thinking of using the solution from the manifest.edn file. Are there some leads? How do you do with Shadow-cljs when an index.html file is used to call the script?


but if you have hiccup you don't need to hook


just read the manifest.edn and generate the script tag from that?


slurp -> edn/read-string and transform it however you need. its just clojure data.

Michaël Salihi10:06:53

> slurp -> edn/read-string and transform it however you need. its just clojure data. Perfect, that's what I'm putting together. Thank you for confirming that I am going in the right direction.

Michaël Salihi10:06:15

I was not aware of this hook, it's wonderful! Thank you

Michaël Salihi10:06:03

@thheller Shadow-cljs is full of hidden gems ... I never regret when I ask questions! 🙂

😎 2
👆 2
Michaël Salihi13:06:34

Another question. If I doesn't the built-in Shadow server and want to watch/reload the CSS file locate in resources/public/css/app.css, what path do I put in {:devtools {:watch-dir "???"}} option?

Michaël Salihi13:06:58

The path must be in the classpath too?

Michaël Salihi13:06:23

I tried multiple solution but no success.


resources/public assuming the file is accessed via /css/app.css in your html

Michaël Salihi13:06:28

Yes, this is the case.

Michaël Salihi13:06:51

Strange, I already try with this path but no success.


you need to restart the watch for this to take effect

Michaël Salihi13:06:40

Oh ok, I try to restart

Michaël Salihi13:06:20

After restarting, I touch resources/public/css/app.css but not rebuild happened


what rebuild do you expect? css is not built by shadow?

Michaël Salihi13:06:34

Yes I know I am using postcss for this. I meant reload


I don't know. what is the EXACT html link tag you use to include it?


and I'm assuming resources/public/css/app.css is the OUTPUT file produced by postcss, not the input?

Michaël Salihi13:06:47

Yes the output file.

Michaël Salihi13:06:51

<link href="/css/app.css" rel="stylesheet" type="text/css">


and your webserver doesn't cache the file or so? I mean what do you see in the browser console? shadow-cljs should be telling you what it is doing

Michaël Salihi13:06:15

I just got it. My public folder does not contain an index.html file as this is handled by hiccup. I thind watch-dir works only with html file, right?


no, doesn't care

Michaël Salihi13:06:58

OK, good to know

Michaël Salihi13:06:20

> and your webserver doesn't cache the file or so? I mean what do you see in the browser console? shadow-cljs should be telling you what it is doing I'll do some tests and I'll tell you


there really isn't much to this. :watch-dir will cause shadow to watch that directory and notify about file updates. the client will look for CSS matches by path and reload if found


again ... look at the console. if you see a load CSS message from shadow-cljs but css didn't update then your server likely caches stuff and didn't return the "new" version


if no load CSS shows up then it didn't match the paths properly

Michaël Salihi13:06:37

Load CSS shows up and CSS reload now, perfect!

Michaël Salihi13:06:36

I think my various tests without restarting shadow-cljs watch misled me. A big thank you again!

Michaël Salihi14:06:04

More I works with Shadow-CLJS and more I'm impressed by the nice piece of librarie that it is! 😉

❤️ 2

I’ve got a function in my app (defn my-fn [x] (do-stuff-with-x)) that gets sent the method toString by some library code. How can I guarantee that toString returns the same value for every build? (I think toString is returning different values because advanced compilation is renaming the function).


I don't understand. "gets sent the method toString by some library code.". what does that mean?


you mean you are calling toString on a function?


sometimes in OOP calling a method is also called “sending a message”


so it looks like myFn.toString()


For some context, the pouchdb library does this to create a unique replication ID


it takes the stringified function, plus some other options to create the unique ID


and if the ID change, it will sync everything (which I’m trying to avoid)


why does it take a stringified function? that sounds like total nonsense?


but there is no way to guarantee that the function will always stay the same with :advanced, at least as far as I'm aware


why can you not choose which string to use? why a stringified function? I don't get it. have some docs?


I believe the idea is that you would want to re-start replication from scratch if any of the parameters for the replication changes


what if I import the function from a javascript module?


and where is that function used? everything going through :advanced or even :simple is never guaranteed to stay identical


I could fork the library (I already maintain a fork of this lib so it wouldn’t be a huge deal)


hmm yeah no clue, I don't see a way to keep this totally stable


I mean any kind of minifier should have this issue? it might end up sort of stable but there is no guarantee


Yeah seems like that would be the case


I’ll search around the issues and stuff to see if anyone else has the same problem


thanks for taking a look with me


I mean you can go totally crazy with hacks but that seems kinda scary


(defn ^:export my-fn [x] ...) and as .filter you use (js/Function. "function filterMe(x) { return _fn(x); }") 😛


or was it (js/Function. "x" "return _fn(x);"), can't remember precisely


kinda absurd to construct a function that way, but that would stay equal 😉


I’ll play around with it, but thank you for suggestions!

Michaël Salihi19:06:02

Me again :) I just finished the Reagent front end integration of this demo app and I'm going to tackle the optimization. For that I use the useful Shadow-cljs report and it seems to me that overall it looks to be well optimized? Someone in the know could give me an opinion? Is there something to do in particular at the level of the CLJS bundle?

Michaël Salihi20:06:01

Or the final size seems reasonable.


looks reasonable. below 150kb gzip is good

Michaël Salihi20:06:57

Perfect, thanks for taking the time 👍