This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (15)
- # babashka (4)
- # beginners (55)
- # calva (92)
- # cider (70)
- # circleci (1)
- # clj-kondo (136)
- # cljdoc (2)
- # clojars (11)
- # clojure (48)
- # clojure-australia (1)
- # clojure-europe (30)
- # clojure-nl (3)
- # clojure-sweden (2)
- # clojure-uk (7)
- # clojurescript (40)
- # conjure (5)
- # core-async (11)
- # cursive (55)
- # data-science (1)
- # datomic (10)
- # degree9 (2)
- # events (1)
- # fulcro (14)
- # gitpod (15)
- # gratitude (13)
- # helix (5)
- # lsp (35)
- # malli (10)
- # meander (18)
- # off-topic (24)
- # pathom (13)
- # polylith (12)
- # practicalli (6)
- # re-frame (13)
- # reagent (33)
- # reitit (4)
- # remote-jobs (1)
- # shadow-cljs (13)
- # spacemacs (31)
- # specter (1)
- # stepwise (2)
- # tools-deps (19)
- # vim (1)
- # xtdb (7)
I'm using a clojurescript repl through emacs + cider. Whenever I do a
println from a not-immeditaly-resolved promise, the output gets lost (e.g. doesn't show up in the repl). The snippet below demonstrates this and is from the promesa docs. If I change the delay to
0, I see the expected output in the repl. If I run the cljs script from the cli, I also see the output.
Any ideas? Or any pointers on where the culprit may be? There's a lot of elements in play here: emacs, cider, shadow-cljs, promesa, cljs compiler, etc, etc.
If by JS console you mean in the brower, this is.a nodejs app. Is there typically a sperate JS console from what I see in the repl?
js/console.log things end up in the repl.
No idea then, I have never tried running CLJS on NodeJS.
js/console.log can easily be overwritten by the REPL machinery to specifically print into REPL.
cljs.core/*print-fn* to do the actual printing, which can also be overwritten by the REPL machinery - only this time not globally but on a per-call basis.
Meaning, the default value of
cljs.core/*print-fn* is something that doesn't print to the REPL.
Maybe something like this could shed some light:
(def orig-print-fn (atom nil)) (-> (p/delay 1000 "") (p/then (fn [_] (reset! orig-print-fn cljs.core/*print-fn*)))) ;; Wait for one second @orig-print-fn
the node repl available for
:node-library builds does not, so there async output just goes to stdout not the REPL
@U05224H0W I'm 'jacking in' and then selecting
node-repl. Does that answer your question?
@U2FRKM4TW when I run your suggestion,
@orig-print-fn shows me the same symbol as
> the node repl available for `:node-script` or `:node-library` builds does not, so there async output just goes to stdout not the REPL I think you're describing what I'm seeing? My async output is going somewhere where I can't see it, but my sync output is going to the repl.
then again, when I jack in, I don't select my specific target,
:app, but select
☝️ confirmed! it was helpful for me to at least narrow it down to a emacs/cider/nrepl issue. now I have a smaller area to investigate.
Interesting wrinkle: When I 'jack in' from emacs, I loose the async println's, but when I start the repl from the cli using
npx shadow-cljs -d nrepl/nrepl:0.9.0-beta1 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.26.0 node-repl and then use emacs to connect to the existing repl, I don't loose the async messages. (They show up in both the emacs repl and on the cli, the former being very convenient)
sorry don't have a clue regarding any emacs/cider stuff.
node-repl should always give you all the output but all shadow-cljs can do is send nrepl messages for those. where or how cider displays them I don't know
I'm trying to add a UI component library (primereact) into a re-frame project but it can't find the dependency to import.. I've been added via yarn, do I also need to add it to, say, shadow-cljs.edn?
Ok, so added it to yarn, tried to require it [primereact :as pr] and get The required namespace "primereact" is not available, it was required by "proj/views.cljs".
Aha, one error closer: The required JS dependency "primereact" is not available, it was required by "pnx_web/views.cljs".
Ok, I think there's no top-level thing to import, it looks like you import per-component, so importing "primereact/button" :as pr-button worked, its just giving me guff here: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
It still seems to be the import problem, but you have advanced a step more. Take a look at this section: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
Thanks.. I've gotten decently familiar with (basic) clojure, and can write angular/react apps all day long, but definitely getting tripped up in the space between at the moment! 🙂
Hi there! I'm trying to learn clojurescript (and clojure!), and I'm having trouble getting things up and running. I compile my .cljs file using lein-cljsbuild, then I import the build code into an .html file using script tags. It seems like the main file cljsbuild generates is inert, though. It's just a bunch of calls to 'goog.addDependency'. I can import 'js/goog/base.js' first, and that allows the code to run without error, but nothing happens. I can then import my script, but I get errors because my dependencies aren't available. I'm pretty sure I need to do something to tell 'goog' to run my script for me, but I can't find any documentation on how to do that. I've read quite a few tutorials and documentation, but I can't find anything that addresses how to run clojurescript code once I've built it, which makes me feel like I'm going crazy.
goog.addDependency without any substance sounds like you're building a development build, not a release one. But maybe that's what you want.
In either case, when you have the main entry point in your script, you have to call it somehow. There are multiple ways, and at least shadow-cljs has something specific to it. But on can override
window.onload, you can export the function and call it explicitly in a separate
<script> tag, or maybe even just call it at the end of the same script where it's defined (probably not great for hot-reloading your code).
Just in case it will look familiar to what lein-cljsbuild has, here's how it would look in shadow-cljs, notice that
:init-fn key: https://shadow-cljs.github.io/docs/UsersGuide.html#_preparing_the_app
I was trying
but a bunch of libraries I use weren't defined. It turns out, I was missing a compiler flag,
(set! (.-onload js/window) (fn  (js/console.log "onready was called") (rdom/render [some-component] (js/document.querySelector ".app"))))
:main "clojure-learning.client", which tells cljsbuild to compile this as an exe and not a library, basically. I added that flag, and now the main.js file looks totally different and runs my code with the correct dependencies imported.
Also, I was ignoring 'shadow-cljs' because I assumed it was a shadow-dom thing, and I didn't care. Now that I see it's a clojurescript build tool, I'll definitely take a look at it.
We've got a library written in clojurescript and I'd like to generate typescript annotations for people using it from typescript-land - has anyone done that before?