Best I can tell shadow is able to send dev builds in a single bundle to the browser
is there any part of the techno wizardry that went in to that which can be used with a deps.edn project?
right now I am working on a project that is using figwheel.main to launch the dev environment, but compared to shadow it is taking forever on refreshes just due to the number of files
and I can't seem to find an option anywhere that would concat those
Hi! I’m using Ubuntu 20.10
@emccue figwheel or cljs.main do not support this feature no. you can just use shadow-cljs with deps.edn if you want.
Hello. I’m writing a library containing just two macros. It’s supposed to work in both CLJS and CLJ (I am having troubles making it work, but that’s a separate issue). It’s a tools/deps project and I have added a shadow-cljs.edn
file to it with a :test
build that runs my (failing) tests. Now I want to connect my REPL to it. I get No JS runtime
if I try to eveluate anything towards the :test
build. Is there a way I could make that work? Guessing not, so next question is how do I create a build that I can connect to and use for REPL-ing? I could make a small webapp, I guess, but it still seems a bit heavier than what I really need. Anyone know of a library project out there I could have a look at?
@pez use shadow-cljs node-repl
or shadow-cljs browser-repl
:test
builds (assuming that is actually :browser-test or :node-test) do not support REPLs
It’s a :node-test
. I’m trying to make it using CLJC, so same tests for Clojure as for ClojureScript. They run, but all fail utterly. I want to be able to load the test file and the tested file in the repl. Tried node-repl
which also gave me No JS runtime
, but I am testing it via Calva, which I haven’t done in a while, so that might be broken. Will try from the prompt now and see what that gives me.
I guess you are launching the REPL wrong
launching node-repl
and then connecting to the test
build instead of the node-repl
?
don't have a clue of calva has a specific option for node-repl
node-repl will ALWAYS have a JS runtime so if you get the no JS runtime error you likely are not actually using that
Yes, Calva has a specific option. But it runs shadow-cljs using npx so my mistake was that I didn’t hava package.json with shadow dev deps. Now it works. I can load my files and my library (that let>
macro stuff you helped me with over at ClojureVerse) also works. That’s great. But the tests are not passing in the :test build. I’ll see if I can figure that out.
Calva also has a browser-repl
option, btw.
good to know
So running the tests taps what I expect them to tap in the shadow-cljs inspector. But the tests add a tap of their own that are then inspected. Works for CLJ, but for CLJS the atom is not updated. The tests all look like this:
(testing "Taps the binding box"
(let [tapped (atom nil)
save-tap (fn [v] (reset! tapped v))]
(add-tap save-tap)
(is (= [:foo :bar]
(sut/let> [foo :foo
bar :bar]
[foo bar])))
(is (= '[[foo :foo]
[bar :bar]]
@tapped))
(remove-tap save-tap)))
Failing like this:
FAIL in (let>) (pez/taplet_test.cljc:20:11)
Taps the binding box
expected: (= (quote [[foo :foo] [bar :bar]]) (clojure.core/deref tapped))
actual: (not (= [[foo :foo] [bar :bar]] nil))
@pez in CLJS the tap is done via setTimeout
so it is async
you can bind your own tap-fn so it stays sync https://github.com/clojure/clojurescript/blob/715cdc07dbb1d595af91ea12affb6faf0b615d4b/src/main/cljs/cljs/core.cljs#L79-L86
Thanks. I know this is not the CLJS support, but anyway, does this look sane enough to your eyes?
(defn sync-fn [f] (f))
(def ^:dynamic *dummy* nil)
(deftest let>
(testing "Evaluates as `let`"
(is (= [:foo :bar] (sut/let> [foo :foo
bar :bar]
[foo bar]))))
(testing "Taps the binding box"
(let [tapped (atom nil)
save-tap (fn [v] (reset! tapped v))]
(add-tap save-tap)
(is (= [:foo :bar]
(binding [#?(:clj *dummy*
:cljs *exec-tap-fn*) sync-fn]
(sut/let> [foo :foo
bar :bar]
[foo bar]))))
(is (= '[[foo :foo]
[bar :bar]]
@tapped))
(remove-tap save-tap)))
...
It works, but ¯\(ツ)/¯well I'd probably swap the binding
to just use do
for CLJ but this is fine too
you can also do #?(:cljs (set! *exec-tap-fn* (fn [f] (f)))
somewhere in that file
not exactly clean but saves having to mess with binding and stuff 😛
Ah, makes sense. Thanks!
What is going on here? Getting this error/warning when starting an app of mine.
error when calling lifecycle function app.core/reload! #error {:message "Unexpected compile spec type", :data {:given nil, :type nil}}
eval @ env.cljs:198
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
G__73437 @ env.cljs:204
eval @ env.cljs:196
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
G__73437 @ env.cljs:204
eval @ env.cljs:233
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
eval @ env.cljs:240
shadow$cljs$devtools$client$browser$do_js_reload @ browser.cljs:49
eval @ browser.cljs:93
eval @ shared.cljs:32
shadow$remote$runtime$shared$process @ shared.cljc:164
eval @ shared.cljs:284
shadow$cljs$devtools$client$shared$remote_msg @ shared.cljs:16
eval @ websocket.cljs:16
Also getting this when dispatching any events (in re-frame), probably nothing to do with shadow, but hey…
yeah not shadow. something you do in the reload!
method throws an exception. no clue what.