Fork me on GitHub
Vincent Cantin04:04:58

Is the usage of ^:const (e.g. in (def ^:const my-var 3000)) still justified when using shadow-cljs?


^:const is probably the most misunderstood feature in CLJ(S) so I would avoid it. but you can use it if you must.

👍 6
Stewart Foxall15:04:19

Hi total newbie here. Just trying out shadow-cljs, but can’t seem to get past the intial step, am getting a binding error. [2021-04-05 15:44:22.985 - WARNING] :shadow.cljs.devtools.server/socket-repl-ex BindException Can’t assign requested address (Bind failed) ( ( (<init> ( shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:123) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:115) shadow.cljs.devtools.server/start-system/fn--17877 (server.clj:233) shadow.cljs.devtools.server/start-system (server.clj:232) shadow.cljs.devtools.server/start-system (server.clj:202) shadow.cljs.devtools.server/start! (server.clj:483) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/start! (server.clj:388) BindException: Can’t assign requested address (Bind failed) ( ( (<init> ( shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:123) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:115) shadow.cljs.devtools.server/start-system (server.clj:248) shadow.cljs.devtools.server/start-system (server.clj:202) shadow.cljs.devtools.server/start! (server.clj:483) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/start! (server.clj:388) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/from-cli (server.clj:615) shadow.cljs.devtools.server/from-cli (server.clj:591) clojure.lang.Var.applyTo ( clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:23) shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:20) shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:129) shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132) clojure.core/apply (core.clj:669) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217) clojure.lang.Var.applyTo ( clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli/-main (cli.clj:75) shadow.cljs.devtools.cli/-main (cli.clj:67) clojure.lang.Var.applyTo ( clojure.core/apply (core.clj:665) clojure.main/main-opt (main.clj:514) clojure.main/main-opt (main.clj:510) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo ( clojure.main.main (


what binding error?

Stewart Foxall15:04:53

Sorry first time using slack and it sent the message before I had finished typing

Stewart Foxall15:04:34

I was using another example, but then switched to using this: I am running on macos 11 if that is relevant


did you block it in your firewall? It needs to open a server socket so you can talk to it via the REPL etc

Stewart Foxall15:04:11

Not as far as I am aware, I have nothing running, checked and can’t see that 8630 port is being used


did you configure anything related to ports in shadow-cljs.edn? or is this with the default setup?


only thing I can think of is your firewall blocking it

Stewart Foxall15:04:27

I did on another example was learning on, but not for quick start. Just followed the commands as is. The file contents is:

;; shadow-cljs configuration


 {8020 "public"}

  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

   {:main ; becomes public/js/main.js
    {:init-fn starter.browser/init}}}}}


that looks fine

Stewart Foxall15:04:18

My firewall is off


you can try adding :socket-repl false so it skips trying to start that


but likely it'll then just fail on the next network port it tries to use

Stewart Foxall15:04:51

and thank you for helping

Stewart Foxall15:04:16

To be clear, you mean like this:

;; shadow-cljs configuration


 :socket-repl false

 {8020 "public"}

  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

Stewart Foxall15:04:00

Errors out again


it tries to bind to by default which should be localhost. I do not know why it would fail. nobody else has reported this before.


or rather for the socket-repl. maybe you only have ipv6 configured? no ipv4 at all?


or rather it tries to bind localhost. is that maybe not configured for some reason?

Stewart Foxall15:04:47

Just taking a look now


try ping localhost in the terminal

Stewart Foxall15:04:33

Looks like something to do with my ISP


that is odd. localhost shouldn't leave you machine at all.


I don't actually know where this is configured in macos anymore. maybe still /etc/hosts?

Stewart Foxall15:04:51

This may be the culprit


my macbook has

$ cat /etc/hosts
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##       localhost broadcasthost
::1             localhost

Stewart Foxall15:04:36

Yes just noticed 127.0.1 was not there, added in and refreshed working now. Thank you!!!!


strange 🙂

Stewart Foxall15:04:17

Very, must have been cleared some point in the past, thanks again…


Is there a way to do dev-only dependencies with shadow-cljs, or do you have to integrate with deps or lein?


wouldn't dev-only dependencies be npm install <package> --save-dev?


Not if it’s a maven/deps package


@max.r.rothman the distinction is not necessary. the builds decide what is included and as such having extra but unused dependencies on the classpath do not matter


just include everything all the time. shadow-cljs.edn itself does not have the concept of dev-dependencies.


Does that happen at all optimization levels? And how then do I configure a build to not include that code (or to only include that code in one build)?


you ns :require forms control what the build will actually use for all optimization levels


the build reports will tell you in detail what your build included


Nice! 🪄


Sounds like there’s not a way to make certain namespaces or dependencies unavailable in certain builds though? I’d have to figure out some way of scraping the build report if I wanted to check that constraint automatically?


you could also verify with a build hook. in general you want to include dev-only code via :preloads. they are not included in the release builds

👍 6

most cljs libs already provide instructions to do so, if that applies


hello, i'm new and i'm using shadow-cljs with cursive, and i can't get command completion to work for a js (actually typescript) library that i installed with npm...should there be a way to make this work?


i created the project using the pom.xml as detailed here:


no, this is currently not support by Cursive


you must use a deps.edn or a project.clj to setup things for Clojure in Cursive


@U01T8T8BL9F with Cursive it's best to use deps.edn or leiningen project.clj for defining dependencies instead of shadow-cljs.edn


ok, thanks everyone, i will give it a try...for now i'm just living with all the unresolved symbols


pom.xml works fine, you do NOT need to use deps.edn or project.clj for Cursive. Regardless of what you use though Cursive does not support JS dependencies as of now


in my experience, there is definitely no need to manage dependencies in deps or project.clj, just want to echo thhellers comment (I find that managing npm deps in shadow-cljs.edn is FAR less maintenance work than dealing with deps.edn or project.clj finagling I end up doing when working with npm deps in those)


Does anyone have any experience building a project with Bazel? Apparently the best angle is to use the Closure rules but does that mean I should npm install shadow-cljs or clojurescript itself?