I don't use them for anything special, other than visualizing in source tree which commit is which release. It's only useful for people looking at the source code.
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.
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) http://java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) http://java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) http://java.net.ServerSocket.bind (ServerSocket.java:375) http://java.net.ServerSocket.<init> (ServerSocket.java:237) 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) http://java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) http://java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) http://java.net.ServerSocket.bind (ServerSocket.java:375) http://java.net.ServerSocket.<init> (ServerSocket.java:237) 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 (Var.java:705) 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 (Var.java:705) 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 (Var.java:705) 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 (Var.java:705) clojure.main.main (main.java:40)
what binding error?
Sorry first time using slack and it sent the message before I had finished typing
I was using another example, but then switched to using this: https://github.com/shadow-cljs/quickstart-browser 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
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
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
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:dev-http
{8020 "public"}
:builds
{:app
{:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules
{:main ; becomes public/js/main.js
{:init-fn starter.browser/init}}}}}
that looks fine
My firewall is off
you can try adding :socket-repl false
so it skips trying to start that
sure
but likely it'll then just fail on the next network port it tries to use
and thank you for helping
To be clear, you mean like this:
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:socket-repl false
:dev-http
{8020 "public"}
:builds
{:app
{:target :browser
:output-dir "public/js"
:asset-path "/js"
yes
Errors out again
it tries to bind to 0.0.0.0
by default which should be localhost. I do not know why it would fail. nobody else has reported this before.
or rather 127.0.0.1
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?
Just taking a look now
try ping localhost
in the terminal
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
?
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.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Yes just noticed 127.0.1 was not there, added in and refreshed working now. Thank you!!!!
strange 🙂
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 https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
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
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?
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)
i created the project using the pom.xml as detailed here: https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive
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
@wrokon with Cursive it's best to use deps.edn
or leiningen project.clj
for defining dependencies instead of shadow-cljs.edn
see https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration
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?
ok, thanks everyone, i will give it a try...for now i'm just living with all the unresolved symbols