This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-04
Channels
- # adventofcode (154)
- # announcements (1)
- # babashka (8)
- # beginners (28)
- # bristol-clojurians (3)
- # calva (131)
- # cider (43)
- # clj-kondo (14)
- # clojure (135)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-madison (1)
- # clojure-nl (6)
- # clojure-spec (8)
- # clojure-uk (90)
- # clojurescript (47)
- # core-async (9)
- # cryogen (4)
- # cursive (12)
- # datomic (9)
- # emacs (7)
- # fulcro (5)
- # graalvm (56)
- # joker (4)
- # juxt (1)
- # leiningen (6)
- # off-topic (62)
- # pathom (4)
- # pedestal (2)
- # reagent (2)
- # reitit (5)
- # ring (2)
- # schema (4)
- # shadow-cljs (133)
- # sql (38)
- # tools-deps (10)
- # vim (28)
Hi. I am reading this https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration and there is this caution which I don't understand. It says use standalone version. Standalone what? Is it telling me to NOT use deps.edn to manage dependencies?
you can use deps.edn but you have been warned when you run into dependency conflict issues and so on
deps.edn is a bit better dealing with those than project.clj but they can still happen
I don't know enough to understand these tradeoffs, so I am inclined to take this as gospel : ). But it feels weird, I thought deps.edn is good.
so, what kind of dependency conflict issues can there be? I mean, if I would use only deps.edn for it? Is this something inherent to clojure/clojurescript ecosystem or just shadowcljs vs the other tools? Sorry if it's the wrong kind of question to ask.
shadow-cljs tries to ensure that you get clojurescript, closure-compiler, closure-library versions that are actually compatible
I see, I didn't realize there could be incompatibilities like that. Thanks for the explanation, I think I will use the built in for now : )
I am testing version 78 and my WebWorkers got broken:
;; for /browser-repl in case the page is reloaded
;; otherwise the browser seems to still have the websocket open
;; when doing the reload
(js/window.addEventListener "beforeunload"
(fn []
(when-let [s @socket-ref]
(.close s))))
browser.cljs:406 Uncaught ReferenceError: window is not defined
at browser.cljs:406
at layout.js:2110
at Array.forEach (<anonymous>)
at Object.env.load (layout.js:2106)
at layout.js:2142
It should probably be js/self instead of js/window in WebWorker.
Not really needed, shadow-cljs has something like figwheel build in, everything works for free.
Is there a way to get the build size report as data, instead of as HTML? Would like to keep a history of build sizes etc somehow.
@pavel.klavik sorry I forgot to document since the feature is kinda unfinished. you can set :devtools {:browser-inject :name-of-the-main-browser-module}
otherwise the browser devtools get injected into the shared module but they don't work in the workers
the build-report stuff sort has its own versioning already built-in its just not accessible from the command line
How does the repl for web workers work?
you can disable the worker inject (to disable hot-reload/REPL) via :worker-inject false
yes. curious why you'd want to use it? as it doesn't allow you to do anything you can't already do in the ns
Got a conditional macro (depending on :compiler-options {:custom-stuff {...}}) choosing what goes into a build.
(prefs/if-cljs-kernel
(require '[pinkgorilla.kernel.shadowcljs :as cljs-kernel])
(require '[pinkgorilla.kernel.mock :as cljs-kernel]))
that doesn't work. I mean it doesn't work in CLJS either. you can't make require
conditional. CLJS stops parsing at the prefs/if-cljs-kernel
Right in the middle of "migrate to shadow-cljs" work (new to it) so I might be missing something.
I get an error complaining that require
cannot be used anywhere other than in the ns
form which is generally not true.
FWIW you can set :build-options {:ns-aliases {pinkgorilla.kernel.shadow-cljs pinkgorilla.kernel.mock}}
I'll see about require
. my assumption always was that it also didn't run macros but I guess it does?
require
outside ns was really meant for scripts that didn't have an ns (which shadow-cljs doesn't support either)
I swear this function is my arch nemesis https://github.com/clojure/clojurescript/blob/6ed949278ba61dceeafb709583415578b6f7649b/src/main/clojure/cljs/analyzer.cljc#L4326 😛
Appears there is an issue with 2.8.78 😉
[:app] Build failure:
IllegalArgumentException: Wrong number of args passed to keyword: :ns-aliases
clojure.lang.Keyword.throwArity (Keyword.java:98)
clojure.lang.Keyword.invoke (Keyword.java:149)
clojure.core/update (core.clj:6200)
clojure.core/update (core.clj:6188)
shadow.build/copy-ns-aliases (build.clj:251)
@thheller I am running Cursive.
@pavel.klavik do you use nrepl?
Yes, nrepl
What would be another option?
you can run (shadow.cljs.devtools.api/repl-runtimes :todomvc-split)
in the clojure REPL
that'd give you something like
[{:runtime-info {:runtime-type :browser,
:lang :cljs,
:build-id :todomvc-split,
:user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.56 Safari/537.36",
:remote-addr "0:0:0:0:0:0:0:1"},
:last-ping 1575462862870,
:last-pong 1575462862872,
:last-msg-received 1575462862872,
:last-pong-runtime 1575462862871,
:connected-since 1575462831938,
:runtime-id "69b97643-1982-4922-b7cf-375bfa7496a8"}
{:runtime-info {:runtime-type :worker,
:lang :cljs,
:build-id :todomvc-split,
:user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.56 Safari/537.36",
:remote-addr "0:0:0:0:0:0:0:1"},
:last-ping 1575462863873,
:last-pong 1575462863874,
:last-msg-received 1575462863874,
:last-pong-runtime 1575462863874,
:connected-since 1575462832785,
:runtime-id "ebd1298e-0201-430b-889b-30bc97eb0103"}]
in theory you should be able to use (shadow.cljs.devtools.api/repl :the-build {:runtime-id "that-runtime-id-from-above"})
I will test it later. But i wouldnt mind to switch to some other repl, Cursive now supports SocketREPL as well.
Not very familar with repls, yet
would be neat if the editor just supported selecting runtimes. I did some experiments with that in the shadow-cljs UI but its all unfinished
I see, it is ok to do this when you dont do it that frequently.
Is it possible to run multiple instances with different runtimes?
Shadow is running nrepl on a port, and i open a window in Cursive which connect there. So the question is whether i can have multiple windows, one for each runtime?
you can open as many nrepl connections as you want yes. and each can talk to a different runtime yes.
I see. Than one could probably bind some keys to do the switching, I will take a look later.
thats the idea behind runtimes as there can always be multiple in a browser env. ie. opening the page in chrome/firefox. or just using workers since they run in their own little world
I see. Make sense, running a page in multiple tabs.
Cornerning hot reloading, I can basically remove restarting the web workers now?
Ok, I will test it later and will let you know.
Just pulled and saw 2.8.79 came out today. Did not expect that I was already lagging. 🙂
Started working on a PR alfready. Did not expect you to react at that pace. Thanks Thomas!
If I pass two target arguments to the shadow-cljs watch
function, shadow-cljs shuts down once the targets are compiled. e.g.:
20:52 $ shadow-cljs watch dev test
shadow-cljs - config: /Users/scott/code/xxxx/shadow-cljs.edn cli version: 2.8.52 node: v12.11.1
...
shadow-cljs - watching build :dev
shadow-cljs - watching build :test
[:dev] Configuring build.
[:test] Configuring build.
[:test] Compiling ...
[:dev] Compiling ...
[:dev] Build completed. (240 files, 1 compiled, 0 warnings, 3.65s)
[:test] Build completed. (240 files, 1 compiled, 0 warnings, 3.67s)
shutting down ...
Worker shutdown.
Worker shutdown.
Works fine and continues to watch when only one target argument is supplied. Am I doing this wrong?The section that I cut out in a failed attempt at helpful brevity was:
shadow-cljs - starting via "clojure"
[2019-12-04T10:13:14,521][INFO ][o.xnio ] XNIO version 3.7.3.Final
[2019-12-04T10:13:14,542][INFO ][o.x.nio ] XNIO NIO Implementation Version 3.7.3.Final
[2019-12-04T10:13:14,581][INFO ][o.j.threads ] JBoss Threads version 2.3.2.Final
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.8.52 running at
shadow-cljs - nREPL server started on port 8777
also try upgrading since I did a bunch of fixes which reduced resource use a bunch. 2.8.80
is latest
it looks like you use macOS which seems to kill the shadow-cljs process sometimes for consuming too much memory
Thank you so much. That’s a good point about memory consumption. I will upgrade and if that doesn’t work, try tweaking the memory settings. Cheers for the incredibly fast response. shadow-cljs really is a fantastic project and a pleasure to use.
confirmed: Upgrading to 2.8.80
worked. No memory constraints required. Thanks again 🙂
man this had me thinking i was going insane https://github.com/thheller/shadow-cljs/issues/612
i guess i can file a jira
I have a stupid question on how to use "deps.cljs" I have a project https://github.com/pink-gorilla/leaflet-shadow/blob/master/src/deps.cljs
Essentially my library is a slim wrapper around react-leaflet. So I think the right place to publish this lib to is clojars...
Hi there! I'm trying to rewrite a project that uses webpack+react to ClojureScript with Shadow-CLJS. The thing is, I don't want to do a "big rewrite", and instead I would like to start migrating existing react components to CLJS little by little.
I though that using :node-library
's target would allow me to integrate with webpack and all other tools on the React side, but its not working (because it needs some of the Node code, like readFileSync
and others). I could use :npm-module
but then I loose the ClojureScript REPL. Is there any alternative?
We're doing something similar with :npm-module
as a target, going outside-in (i.e. from the leaves). We still use the REPL
These had to be added on the js entrypoint: (`cljs/` ` is a webpack alias pointing to the cljs build folder)
window.CLOSURE_BASE_PATH = '/javascripts' // Should match your assets location
require('cljs/shadow.cljs.devtools.client.browser') // REPL
require('cljs/shadow.remote.runtime.cljs.browser') // Shadow's Inspect
Great, I'm gonna test right now 🙂
Just for the record, if I add [shadow.cljs.devtools.client.browser]
on one of the required namespaces, it works too 🙂
@hoertlehner yes that should work fine?
@mauricio.szabo :node-library
presumes node
not webpack + browser.
Is :npm-module
able to run before/after load code?
I'm not seeing it working on my setup
(in fact, I'm not sure the hot reload is working either)
@mauricio.szabo in general hot-reload and REPL are a bit constrained when running through webpack. it sometimes work if you require the REPL ns separately from JS