Fork me on GitHub
#shadow-cljs
<
2023-03-27
>
Jakub Šťastný02:03:57

Hey guys, I'm having issues with eval. My code is simple:

+  (let [list [::labour ::material ::other]]
+    (doseq [name list] (s/def name price-validator))
+    (cljs.core/eval `(s/def ::cost-of-sale (s/keys :opt-un ~list))))
But I'm getting: cljs.core/*eval* not bound". Do I need to do any setup for it to work?

thheller06:03:33

eval is only available in self-hosted environments. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html

👍 2
thheller06:03:13

which has significant impact on build size and stuff, so make sure you really really need it.

souenzzo12:03:31

Checkout "eval in clojurescript" section https://github.com/babashka/sci sci is probably simpler to build.

👍 2
Jakub Šťastný12:03:19

@U05224H0W I see. OK I find another way then.

pmooser12:03:15

Can :target :node-script work with :js-provider :external ? I'm guessing probably not ?

thheller13:03:29

no, that is strictly a browser thing

pmooser13:03:42

Ok, thank you.

Tyler Nisonoff16:03:20

Ive ran into an issue a few times where after adding a new JS package and yarn installing , and restarting shadow i start to get:

ReferenceError: $jscomp is not defined
in my console Blowing out the shadow cache and my output dir and restarting shadow fixes things, but I know this should not be necessary. How would i investigate further?

thheller17:03:17

did you reload the browser or did the error appear during a repl/hot-reload?

thheller17:03:56

it is known that polyfills aren't injected for the REPL or hot-reload but usually just reloading the browser should make them available

thheller17:03:06

otherwise I don't know. $jscomp is polyfill related

Tyler Nisonoff17:03:15

this was after reloading the browser

thheller17:03:50

are you manually setting a old :output-feature-set?

cjohansen17:03:30

I’ve setup a shadow project according to the quickstart, using deps.edn for dependencies, and starting the REPL via clj. I have a dependency with resources on the classpath, e.g. resources/public/… and its deps.edn specifies :paths ["src" "resources"] . My shadow-cljs.edn looks like this:

{:deps true

 :dev-http {8080 "public"}

 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn sample.core/init}}
   }}}
How can I get the dependencies’ resources served over localhost:8080 alongside my local resources?

thheller17:03:14

:dev-http {8080 "classpath:public"} assuming they are all on the classpath in the public dir

thheller17:03:15

:dev-http {8080 ["public" "classpath:public"]} if you also want to use the regular public folder

cjohansen17:03:33

Yeah, I figured 😅

thheller17:03:33

picks files in public first, then checks the classpath if none match

cjohansen17:03:42

Yep, got it working, thanks 👍