Fork me on GitHub
#shadow-cljs
<
2024-04-21
>
3starblaze06:04:38

I want to make dynamic builds (builds that are not defined in shadow config) and a cljs dependency is not found and I am not sure where is the problem. Expected a successful compilation but got "reagent.core" is not available, it was required by "bar/ns.cljs". The dependencies worked fine when I had everything in shadow config. (Simplified code in thread)

3starblaze06:04:54

Here is a simplified code that shows what I am doing right now

;; src/baz/fe_build.clj
(ns baz.fe-build
  (:require
   [shadow.cljs.devtools.api :as shadow-api]
   [shadow.cljs.devtools.server :as shadow-server]))

(defn watch
  {:shadow/requires-server true}
  []
  (shadow-server/start!)
  (shadow-api/watch
   {:build-id :foo,
    :target :browser,
    :output-dir "builds/foo/js",
    :asset-path "/foo/js",
    :modules {:main {:init-fn bar.ns/main}}}))

;; src/bar/ns.cljs
(ns bar.ns
  (:require
   [reagent.core :as r]))

;; shadow-cljs.edn
{:source-paths
 ["src"]

 :dependencies
 [[reagent "1.2.0"]]}

thheller06:04:39

and how did you call this watch function? I mean how was the JVM launched

thheller06:04:39

then dependencies need to be defined in deps.edn

3starblaze06:04:18

Oh, so those dependencies in shadow config work like regular Clojure dependencies?

thheller06:04:19

{:shadow/requires-server true} is only relevant when using npx shadow-cljs run

thheller06:04:01

I mean clj launches the JVM then nothing even looks at shadow-cljs.edn for dependencies

3starblaze06:04:14

Oh okay, I thought they are somewhat special because they are meant for cljs. Thanks for the quick response!

thheller06:04:36

nope, just regular dependencies like any other

👍 1
thheller06:04:04

same for :source-paths. also not used when launched via clj

👍 1