Fork me on GitHub
#shadow-cljs
<
2024-03-24
>
chaos18:03:36

Hello, I've noticed a slight variance in behavior regarding deps.cljs when I execute a watch command from the command line (e.g., shadow-cljs watch app) compared to running it via the API (e.g., (shadow/watch :app)). It appears that the latter disregards any additional deps.cljs dependencies originating from ClojureScript packages. Is this the intended behavior?

chaos18:03:22

The deps.cljs logic seems to be originating from the below main function (via install-deps), which made me think this might be the entry point for the standalone cli invocation, and this is why is not available by the API? https://github.com/thheller/shadow-cljs/blob/7f6bec693c1914c8eb463f6016cfa871ffb593d2/src/main/shadow/cljs/devtools/server/npm_deps.clj#L167-L182

thheller20:03:17

well you can just call it

thheller20:03:44

I don't consider this as something you should rely on for anything, so frankly I regret even adding it, the automatic install that is. it should have been a manual command

thheller20:03:58

you should manage your npm dependencies via package.json

chaos20:03:21

Right, in my situation I was very much surprised first to see package.json automagically updating itself when the shadow starter app was consuming a package that had a eps.cljs . It took me some time of head scratching to find out where this was coming from. I was equally surprised a second time when I tried to consume the same package from another starter app which was invoked via the API, but nothing happened.

chaos20:03:15

So I wasn't introducing a deps.cljs, but consuming one from an external package, and since I didn't know about this feature, it was confusing.

chaos20:03:03

Seems like a good feature though, to be able to automatically induce the npm dependencies of an external clojurescript package.

thheller20:03:02

yeah, but is has a couple issues so I don't like it very much in its current form

thheller20:03:07

don't have any better idea though

chaos20:03:03

I can think of some options going forward 1. Update the message when the update happens to indicate this is comfing from a deps cljs file, currently the message is

$ shadow-cljs watch dev
...
shadow-cljs - starting via "clojure"
running: cmd /C yarn add --exact  ...
which does not indicate to the user where this update is coming from (I didn't even realilize this is coming from shadow) 2. Update the API call so that it also considers deps.cljs 3. Update relevant section documentation to indicate any difference in behavior calling from CLI/API, and perhaps put a note that this feature has some issues (linking to GH issue?) and should be avoided

chaos20:03:24

I can do a PR if you find any of these worthwhile