Fork me on GitHub
Drew Verlee15:06:16

if there is a clj reader conditional on the path will shadow evaluate it? it seems like the answer is yes. e.g some .cljc file with (defn foo [] #?(:clj .... shadow watch is going to read the :clj text.


@drewverlee I don't understand the question? of course it is going to read it. it won't use it though unless in macro context?

Drew Verlee15:06:51

what's happening is that the :clj reader conditional requires a dependency that's only used for clj. So the shadow-cljs.edn file has to accumulate these clj deps or throw an error if i forgot to include it. The clj deps won't effect the build javascript target, but i'm contemplating if i should structure the dependencies differently. I'll have to move the cljc dependencies to their own project outside shadow so they can be used by the server. At the moment i just copied the logic over. I'm trying to convert a boot project to shadow and it has a large .cljc util namespace.


I assume you are referring to the alias missing? so it fails to read? otherwise the lack of dependencies shouldn't matter at all? unless you :require-macros that namespace it won't actually be loaded or evaluated?


but if you have (:require [some.thing :as x]) in the :clj branch


and then later x/whatever in the :clj branch again that can't be read by the reader if that alias doesn't exist in cljs too


otherwise I'm not sure what the problem is?

Drew Verlee16:06:16

The cljs code pulls in functions via :require-macros, then as i understand it, it goes to read the :clj branch as well and is like "you don't have that dependency" because i didn't port the clj library because it felt weird (i didn't realize i had to) to move that into a shadow project. Something like org.clojure/data.csv.


the cljs code can't pull in functions via :require-macros. only macros?

👍 1

but yes, :require-macros will cause the namespace to be evaluated by clojure. and complain about missing dependencies.


and it is loaded as a regular clojure namespace, nothing shadow related at all in that case

Drew Verlee16:06:28

That makes sense. I'll think about this a minute and see if i can come up with something or a better question 🙂