This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-14
Channels
- # aleph (2)
- # atlanta-clojurians (5)
- # beginners (38)
- # boot (2)
- # bristol-clojurians (1)
- # cider (31)
- # clara (8)
- # cljs-dev (136)
- # cljsrn (4)
- # clojure (86)
- # clojure-china (1)
- # clojure-greece (1)
- # clojure-italy (24)
- # clojure-nl (1)
- # clojure-spec (21)
- # clojure-uk (19)
- # clojurescript (68)
- # community-development (28)
- # core-async (35)
- # core-logic (4)
- # cursive (1)
- # data-science (1)
- # datascript (1)
- # datomic (46)
- # events (1)
- # figwheel (6)
- # fulcro (11)
- # graphql (3)
- # hoplon (1)
- # jobs (6)
- # jobs-discuss (94)
- # keechma (3)
- # luminus (4)
- # lumo (7)
- # mount (6)
- # off-topic (24)
- # onyx (6)
- # parinfer (31)
- # portkey (3)
- # programming-beginners (16)
- # re-frame (20)
- # reagent (69)
- # remote-jobs (4)
- # ring-swagger (25)
- # schema (1)
- # shadow-cljs (151)
- # spacemacs (2)
- # sql (14)
- # tools-deps (16)
- # uncomplicate (5)
- # unrepl (35)
- # vim (1)
- # yada (72)
weird edge case I just found: I had a .cljc
namespace which used defmacro
, but did not include a (:require-macros [...self...])
in the ns form.
this was in a utility library I used in Maria. Whenever I would compile the ‘browser’ build and the ‘bootstrap’ build together, this still worked as expected, so I had no idea I had even made a mistake. But if I would compile the ‘browser’ build independently from the ‘bootstrap’ build, I wouldn’t get a warning, but cljs would treat the defmacro
as a function and return the unevaluated form.
It only showed up when I split these builds for circleci (I’m using tools.deps now, and that increases memory usage, so I can’t compile all the builds in one step anymore)
ah right you limited the memory via jvm-opts. those are probably not yet passed onto tools.deps
I don't know about the defmacro
thing. one build should not affect the other since they are completely isolated
[:bootstrap] Compiling ...[:live] Compiling ...[:trusted] Compiling ...
/usr/local/bin/clojure: line 342: 316 Killed "$JAVA_CMD" "${jvm_cache_opts[@]}" "${jvm_opts[@]}" -classpath "$cp" clojure.main "${main_cache_opts[@]}" "$@"
Exited with code 137
Hint: Exit code 137 typically means the process is killed because it was running out of memory
Hint: Check if you can optimize the memory usage in your app
Hint: Max memory usage of this container is 4287946752
according to /sys/fs/cgroup/memory/memory.max_usage_in_bytes
well they do share the same clojure vm instance. so if one defines a var the other can see it
yes, unless you care about self-host in which case I don't have an easy answer for oyu
(defmacro deftime
"This block will only be evaluated at the correct time for macro definition, at other times its content
are removed.
For Clojure it always behaves like a `do` block.
For Clojurescript/JVM the block is only visible to Clojure.
For self-hosted Clojurescript the block is only visible when defining macros in the pseudo-namespace."
[& body]
(when #?(:clj (not (:ns &env)) :cljs (re-matches #".*\$macros" (name (ns-name *ns*))))
`(do [email protected])))
incidentally this util macro itself uses macrovich, to use keyword-identical?
for cljs and identical?
for clj
does your build actually work when running both builds? or does it just not complain?
------ WARNING #1 --------------------------------------------------------------
File: C:\Users\thheller\code\shadow-cljs\src\dev\demo\browser.cljs:24:2
--------------------------------------------------------------------------------
21 | (defmacro dummy-macro [& body]
22 | (prn :foo))
23 |
24 | (dummy-macro 1 2 3)
--------^-----------------------------------------------------------------------
Use of undeclared Var demo.browser/dummy-macro
--------------------------------------------------------------------------------
makes sense I guess although the warning is a little bit weird since the defmacro
is right there 😛
it’s the non-locality that made it so weird. not requiring a clj namespace in one part of the project suddenly means that a cljs namespace somewhere else treats a macro like a function
yeah it is definitely a weird issue. I blame https://dev.clojure.org/jira/browse/CLJS-2454 for not properly checking if macros are actually referred and blindly using them. defmacro
is also to blame though.
@mhuebert just pushed [email protected]
. it probably breaks all the self-host stuff. please test.
just the usual:
------ WARNING #1 --------------------------------------------------------------
File: cljs/spec/test/alpha$macros.cljc:113:35
--------------------------------------------------------------------------------
110 | ([xs]
111 | `(instrument ~xs nil))
112 | ([sym-or-syms opts]
113 | (let [syms (sym-or-syms->syms (eval sym-or-syms))
-----------------------------------------^--------------------------------------
Use of undeclared Var cljs.spec.test.alpha$macros/eval
--------------------------------------------------------------------------------
114 | opts-sym (gensym "opts")]
115 | `(let [~opts-sym ~opts]
116 | (reduce
117 | (fn [ret# [_# f#]]
---------------------------------------
@fbielejec I think cider-jack-in
starts a new lein
process, so it won't find the one started by shadow-cljs watch
so you can do this https://shadow-cljs.github.io/docs/UsersGuide.html#embedded
(require '[shadow.cljs.devtools.server :as server])
(server/start!)
(require '[shadow.cljs.devtools.api :as shadow])
(shadow/watch :foo)
(shadow/nrepl-select :foo)
can I invoke a watcher like this too? e.g.
(shadow.cljs.devtools.server/start!)
(shadow.cljs.devtools.api/watch :dev)
(shadow.cljs.devtools.api/nrepl-select :dev)
btw :dev
is a built-in concept of shadow-cljs
. every build has a dev and release mode
in shadow-cljs its just shadow-cljs release the-build
or shadow-cljs watch the-build
it's just scattered a bit, but the fact I can get npm packages working out of the box is worth spending some time searching 🙂 It's awesome.
Ok, so I killed the watcher in the terminal, create a user ns with these invocations
shadow-cljs - HTTP server for :app available at
shadow-cljs - server running at
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "cljs-0x-connect.dev" is not available.
To quit, type: :cljs/quit
[:selected :app]
mar 14, 2018 12:02:49 PM clojure.tools.logging$eval8628$fn__8631 invoke
WARNING: stale websocket client, no worker for build :dev
wondering why you get the build failure? did it work when running shadow-cljs watch
?
please don't ever clean
the .shadow-cljs
dir. :clean-targets ^{:protect false} ["target" "public/js" "node_modules" ".shadow-cljs"]
gotcha. Ok so the build failure happened because "src" was not in :source-paths ["src" "dev"]
I incorrectly assumed it is handled by the shadow-cljs, since I specify the :source-paths ["src"]
there too
as soon as you set :lein
:dependencies
and :source-paths
are managed by lein
and no longer mean anything in shadow-cljs.edn
ok so very close now:
user> (start-dev!)
mar 14, 2018 12:17:48 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
mar 14, 2018 12:17:48 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :app available at
shadow-cljs - server running at
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (226 files, 124 compiled, 0 warnings, 29,07s)
To quit, type: :cljs/quit
[:selected :app]
user> JS runtime connected.
@mitchelkuijpers has cider
experience. I don't really know anything about cider
@fbielejec if you figure it out let me know please. want to finally have something I can put into the docs. 🙂
I will, off course. Btw I notice the same behaviour (no cljs REPL) when just calling lein repl
and then starting the server, watcher and repl using the API.
something in cider is supposed to clone the session so you have one for clj and one for cljs
@fbielejec did you figure it out?
No, we have been working with cider for 2 months now 😛
Yes you are completely right
is the emacs/cider integration fully functional with a cljs nrepl? i.e., does it allow you to send forms, get documentation strings, do tab completion, find definitions, stuff like that?
@lee.justin.m yes all works
@lee.justin.m fairly certain the same setup should work for Cursive too
expect Cursive
that's the minimum time span one should spend before switching editors 😛. It's really paramount for productiveness imho, whatever the choice might be in the end.
agreed, I spent almost 8 years on Vim before moving to intellij stuff, I used to spend around 10 ~ 20% of my time tweeking my editor, in Intellij I don't have as much customizations, instead I just use it as is mostly (except for snippets and some repl commands) and I'm very happy with not having to configure things all the time
I'm very happy with Cursive for the time being. Never want to back to emacs as well.
It asked if I wanted to index the remote repositories and I said yes. I’m worried i just told cursive to go index everything on maven and clojars.
the clojars index in a decent time, the maven can take forever
so do i need to do anything special to get an nrepl to connect to shadow? I put in the localhost/9000 (which is what my nrepl is configured to), it just hangs on `Connecting to remote nREPL server... Clojure 1.9.0`. i confirm that it works if i connect using the terminal.
it doesn't print anything else. you should be connected. just eval something to test
that still doesn’t work.
Connecting to remote nREPL server...
Clojure 1.9.0
(js/console.log "HELLO")
CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(null:1:1)
(+ 1 1)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(null:1:1)