This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-17
Channels
- # announcements (10)
- # aws (10)
- # babashka (11)
- # beginners (77)
- # calva (9)
- # cider (10)
- # cljdoc (7)
- # cljs-dev (47)
- # clojure (47)
- # clojure-uk (4)
- # clojurescript (87)
- # community-development (15)
- # conjure (14)
- # core-async (25)
- # cursive (6)
- # fulcro (6)
- # helix (3)
- # joker (2)
- # nrepl (1)
- # off-topic (1)
- # pathom (9)
- # pedestal (6)
- # re-frame (22)
- # reitit (15)
- # shadow-cljs (26)
- # spacemacs (16)
- # testing (2)
- # tools-deps (12)
- # uncomplicate (10)
- # xtdb (22)
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.
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 '[clojure.data :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 '[clojure.data :as data])
------ REPL Error while processing ---------------------------------------------
(require '[clojure.data :as data])
no source by id: [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]
{:id [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]
shadow.build.data/get-source-by-id (data.clj:171)
shadow.build.data/get-source-by-id (data.clj:168)
shadow.build.compiler/remove-dead-js-deps/remove-fn--13854/fn--13855 (compiler.clj:1164)
clojure.core/complement/fn--5669 (core.clj:1441)
clojure.core/filter/fn--5893 (core.clj:2817)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
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)
shadow.build.compiler/remove-dead-js-deps/remove-fn--13854 (compiler.clj:1166)
clojure.core/update (core.clj:6196)
clojure.core/update (core.clj:6188)
shadow.build.compiler/remove-dead-js-deps/fn--13859/fn--13860 (compiler.clj:1172)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
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)
shadow.build.compiler/remove-dead-js-deps/fn--13859 (compiler.clj:1173)
clojure.core/update (core.clj:6196)
clojure.core/update (core.clj:6188)
shadow.build.compiler/remove-dead-js-deps (compiler.clj:1170)
shadow.build.compiler/remove-dead-js-deps (compiler.clj:1159)
shadow.build.compiler/compile-all (compiler.clj:1422)
shadow.build.compiler/compile-all (compiler.clj:1269)
shadow.build.api/compile-sources (api.clj:258)
shadow.build.api/compile-sources (api.clj:250)
shadow.build.api/compile-sources (api.clj:262)
shadow.build.api/compile-sources (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 (MultiFn.java:234)
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)
java.lang.Thread.run (Thread.java:830)
(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 '[clojure.data :as data])
=> nil
1
=> 1
(data/diff [1 2 3] [4 5 6])
=> [[1 2 3] [4 5 6] nil]
@orestis https://shadow-cljs.github.io/docs/UsersGuide.html#_contributing very welcome
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?
it is simply a limitation of the JS platform. we cannot do sync IO, which require
would need.
in case someone is interested in WASM related things https://www.reddit.com/r/Clojure/comments/gloazr/using_wasm_in_cljs/