Fork me on GitHub

I’m building a library that I want to be compatible with both stable and experimental React. So when testing I need to bounce back between the two versions. I can probably detect the presence of functions at runtime, or I could have two different namespaces (one for stable and one for experimental), letting the user decide which to use.


But when I’m developing the library, is there a way to test things out without too much hassle? My current thinking is to put the testing/demo stuff in a different project and use the library as a local root dep. Then I’d fire up two shadow-cljs instances, each one with a different node_modules.


no clue? seems like more of a npm question than a shadow-cljs question 😛


I'd probably take your appraoch of 2 separate builds with two separate folders


I’ll play around. I assume shadow looks for node_modules next to shadow-cljs.edn?


Btw where is the source for this guide? Would be nice to submit PRs ( if welcome)


When you’re performing a require in the namespace in shadow-cljs, you have to add it to the ns form right? Shadow doesn’t like you referring to a namespace alias you defined outside that?


Using code in editor sent to clojure repl:

(require '[ :as data])
(data/diff [1 2 3] [4 5 6])
=> nil
=> [[1 2 3] [4 5 6] nil]
Using code in editor sent to shadow repl:


(require '[ :as data])
------ REPL Error while processing ---------------------------------------------
(require '[ :as data])
no source by id: [ "terrain_cljs/core_test.cljs"]
{:id [ "terrain_cljs/core_test.cljs"]}
ExceptionInfo: no source by id: [ "terrain_cljs/core_test.cljs"] (data.clj:171) (data.clj:168) (compiler.clj:1164)
	clojure.core/complement/fn--5669 (core.clj:1441)
	clojure.core/filter/fn--5893 (core.clj:2817)
	clojure.lang.LazySeq.sval (
	clojure.lang.LazySeq.seq (
	clojure.lang.ChunkedCons.chunkedNext (
	clojure.core/chunk-next (core.clj:708)
	clojure.core.protocols/fn--8154 (protocols.clj:137)
	clojure.core.protocols/fn--8154 (protocols.clj:124)
	clojure.core.protocols/fn--8114/G--8109--8123 (protocols.clj:19)
	clojure.core.protocols/seq-reduce (protocols.clj:31)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887) (compiler.clj:1166)
	clojure.core/update (core.clj:6196)
	clojure.core/update (core.clj:6188) (compiler.clj:1172)
	clojure.core/map/fn--5866 (core.clj:2753)
	clojure.lang.LazySeq.sval (
	clojure.lang.LazySeq.seq (
	clojure.lang.RT.seq (
	clojure.core/seq--5402 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887) (compiler.clj:1173)
	clojure.core/update (core.clj:6196)
	clojure.core/update (core.clj:6188) (compiler.clj:1170) (compiler.clj:1159) (compiler.clj:1422) (compiler.clj:1269) (api.clj:258) (api.clj:250) (api.clj:262) (api.clj:250)
	shadow.cljs.repl/repl-require (repl.clj:218)
	shadow.cljs.repl/repl-require (repl.clj:187)
	shadow.cljs.repl/process-read-result (repl.clj:522)
	shadow.cljs.repl/process-read-result (repl.clj:502)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:879)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:833)
	shadow.cljs.devtools.server.worker.impl/eval16051/fn--16052 (impl.clj:914)
	clojure.lang.MultiFn.invoke (
	shadow.cljs.devtools.server.util/server-thread/fn--15579/fn--15580/fn--15588 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--15579/fn--15580 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--15579 (util.clj:257) (
(data/diff [1 2 3] [4 5 6])
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: :1:2
 No such namespace: data, could not locate data.cljs, data.cljc, or JavaScript source providing "data"
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:2
 Use of undeclared Var data/diff
ReferenceError: data is not defined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:1)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()


Manually pasting the form:

(require '[ :as data])
=> nil
=> 1
(data/diff [1 2 3] [4 5 6])
=> [[1 2 3] [4 5 6] nil]


@folcon you can't define a namespace alias outside the ns


In shadow? It works in the normal repl, just tested it…


REPL is a special case


it does not work in regular files


Ah, sure =)…


Sorry, just to be clear, In both cases I’m performing send form to repl in a file, not pasting straight into the repl?


Let me check in a clj file (as opposed to user.clj), you’re almost certainly right however =)…


No, that seems to work as well? To be honest, I’m not really bothered, it’s an easy thing to just add the form to the file. I’m more surprised that this requires special handling, I would have thought this sort of functionality would have been part of the reader?


CLJ is different ...


That’s fair =)…


it is simply a limitation of the JS platform. we cannot do sync IO, which require would need.


Good to know


in case someone is interested in WASM related things

👀 4
👏 8
🎉 8