shadow-cljs

Hendrik 2025-01-26T09:35:24.914759Z

I have cljc code, that I want to publish as a library. The cljs part uses some npm dependencies. What is recommended way to deal with the npm depenencies? Is it possible to bundle them with the library? Or is it possible to add the dependency information, so that shadow-cljs as a consumer of the library can fetch the npm deps. Or there is no way to add the deps and I should mention in the docs that a library consumer must add deps xzy to its package.json file?

👍 1
thheller 2025-01-26T09:36:12.494449Z

you can add a deps.cljs file to the library jar and have that include {:npm-deps {"that-dep" "the-version"}}

thheller 2025-01-26T09:36:40.874899Z

shadow-cljs will by default run npm install that-dep@the-version if it finds such a file

Hendrik 2025-01-26T10:48:12.376859Z

Thanks. I will give it a try.

Hendrik 2025-01-26T11:35:51.883299Z

Where in the src-tree do I have to place that file?

thheller 2025-01-26T11:44:57.138269Z

in the jar at the root

Hendrik 2025-01-26T11:50:08.808679Z

I have a file called deps.cljs with this content at my jar root

{:npm-deps {"three" "0.143.0"}}
at the jar root. but the dependency does not get installed. Do I have to some more settings? And for information I am using electric v3 , so electric starts shadow,but from what I can see, that should not matter, or should it?

thheller 2025-01-26T11:50:57.242589Z

that does matter. no clue how electric starts shadow, but it could easily be skipping that install step

Hendrik 2025-01-26T11:51:30.642099Z

(shadow-server/start!) 
 (shadow/watch :dev)

Hendrik 2025-01-26T11:52:05.405059Z

shadow-cljs.edn is:

{:builds
 {:dev  {:target :browser
         :devtools {:loader-mode :default, :watch-dir "resources/public/electric_starter_app"}
         :output-dir "resources/public/electric_starter_app/js"
         :asset-path "/js"
         :modules {:main {:entries [dev] :init-fn dev/start!}}
         :build-hooks [(hyperfiddle.electric.shadow-cljs.hooks3/reload-clj)]}
  :prod {:target :browser
         :output-dir "resources/public/electric_starter_app/js"
         :asset-path "/js"
         :modules {:main {:entries [prod] :init-fn prod/start!}}
         :module-hash-names true}}}

thheller 2025-01-26T11:52:10.619129Z

yes, that bypasses it

thheller 2025-01-26T11:52:56.885479Z

this is the function that handles the install. I guess you could call it manually

Hendrik 2025-01-26T12:18:44.558629Z

Yes. Running npm-deps/main manually worked. Thank you very much for your support and advice 🙂

manas_marthi 2025-01-26T10:30:34.669079Z

Is there a luminous template or some other template to create a GCP Serverless NodeJS project that runs on GCP backed by Firebase and uses simple EJS or SELMER templates and no Reagent/Reframe/React?