This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-02
Channels
- # announcements (11)
- # aws (3)
- # babashka (34)
- # beginners (20)
- # biff (2)
- # calva (3)
- # cherry (29)
- # cider (6)
- # cljs-dev (9)
- # clojure (124)
- # clojure-europe (12)
- # clojure-norway (5)
- # clojure-uk (2)
- # clojurescript (32)
- # conjure (11)
- # datalevin (1)
- # datomic (16)
- # deps-new (1)
- # etaoin (6)
- # holy-lambda (10)
- # honeysql (28)
- # hyperfiddle (21)
- # jackdaw (2)
- # jobs (2)
- # leiningen (15)
- # missionary (12)
- # off-topic (132)
- # other-languages (1)
- # pathom (13)
- # rdf (10)
- # re-frame (8)
- # reagent (5)
- # releases (1)
- # remote-jobs (4)
- # shadow-cljs (32)
- # tools-deps (6)
- # vim (15)
- # xtdb (24)
What's the simplest way in Clojurescript to spawn a subrepl such that every time you evaluate something, "Yay!" is printed before the result is returned? Either via macro or in cljs directly? Preferably without bringing in all the self-host machinery?
I basically want to wrap the evaluation context in an extra function that ships the evaluation to a specific webworker
Also, I'd like to be able to do this to easily create sub-sub repls, so that I can evaluate code in the context of a stepping dbg evaluation context
With inmesh's blocking semantics, I have a basic stepping debugger working, where you just wrap your code in (dbg ...
and then when it halts, you can check the value of local vals with (dbg-> ...
, But it'd be nice to be able to not have to use dbg->
and just automatically get a sub-repl that has the dbg->
built in, until you exit out of it
@john not possible in any of the default REPL impls, not even self-hosted if by REPL you mean evaluating something from your editor. You'd basically have to build your own from scratch.
I mean the challenge is that in all regular REPLs the RL
happens in CLJ but EP
in JS
It would be nice to not have to wrap the repl though, and instead do something like set-pre-eval-hook-fn!
so you could just reuse the existing repl
its more of a read -> compile to js -> send to runtime -> eval in runtime -> print in runtime -> send to server -> print in server -> loop loop 😉
set-print-fn!
works, allowing me instrument the P step, to catch prints and send them to a particular worker. I essentially want that for instrumenting the E step
Or maybe just a macro that blocks for user input. Would be nice if there was a line-number-push-back reader thing built right in, that unblocked after a form is closed. And then I could handle the looping on the CLJS side
No, the CLJS side can't reinvoke the blocking macro :thinking_face: would have to loop on the CLJ side, but then releasing forms to the CLJS repl on each loop becomes a problem, hmm
Interesting thing about the debugger, it inverts control of the loop to the CLJS side, inside the worker, so:
(dbg
(let [x 1 y 3 z 5]
(println :starting)
(dotimes [i z]
(break (= i y))
(println :i i))
(println :done)
4))
;:starting
;:i 0
;:i 1
;:i 2
;=> :starting-dbg
It'll then just hang at the break
, waiting for messages from other workers. Sending it a message like (in? i)
makes it send back 3
and it just keeps looping, letting you inspect the locals. Finally,
(in? :in/exit)
;:i 3
;:i 4
;:done
;=> 4
And it exits. So most of the REPL parts are there. I just need a way to tie the existing repl to it, essentially wrapping the result of the existing Read with a (in? ...)
I guess you don't need the outer dbg
. That's just a convenience thing. You could drop break
s into regular worker code and it'll enter the break loop, waiting for messages, and after exit it'll continue normal execution
I want to start investigating how to reduce my bundle size - is there a way to get the post-closure-compiler size for each of my dependencies? What sort of size analysis tools are available?
@thheller, something like npx shadow-cljs run shadow.cljs.build-report app output.html
?
yes, shadow-cljs has build reports https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
These build reports are a godsend! Thank you for adding that, I've now got some low-hanging fruit to saw off : )
Arf not fast enough compare to @thheller 😁
Unfortunately I'm not currently using shadow-cljs, though this may be an inducement to switch
i used https://www.npmjs.com/package/source-map-explorer in the past
I need to import and re-use some react components from a vanilla .js lib. Unfortunately, it's a closed-source project otherwise I'd share a link.
I'm trying to require things directly in my project (shadow-cljs), but it chokes on sass imports. The .js code has lines like import "./Accordion.scss"
.
Does that mean that I have to prep this lib somehow, re-bundle it with webpack or something (I dunno), to be able to use it in cljs project?
yes, this requires webpack. you can use it to bundle all your JS dependencies via this https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
I am running lein uberjar on a reagent project and am getting the following error. How can I fix this?