This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-27
Channels
- # announcements (1)
- # aws (10)
- # babashka (53)
- # calva (133)
- # clj-kondo (46)
- # cljdoc (6)
- # cljs-dev (33)
- # clojure (105)
- # clojure-boston (1)
- # clojure-europe (11)
- # clojure-nl (4)
- # clojure-poland (1)
- # clojure-switzerland (6)
- # clojure-uk (13)
- # clojurescript (106)
- # cursive (1)
- # datascript (2)
- # emacs (13)
- # events (1)
- # figwheel-main (4)
- # fulcro (17)
- # graphql (8)
- # heroku (2)
- # honeysql (8)
- # lsp (76)
- # luminus (30)
- # malli (12)
- # meander (23)
- # music (1)
- # nextjournal (83)
- # off-topic (6)
- # pathom (3)
- # polylith (19)
- # re-frame (8)
- # reagent (2)
- # reveal (3)
- # shadow-cljs (54)
- # sql (9)
- # testing (11)
- # tools-deps (15)
- # xtdb (14)
@ben.hammond shadow-cljs clj-repl
and then (shadow/repl :foo {:runtime-id 123})
where the runtime id is either listed here http://localhost:9630/runtimes or in the browser console on start shadow-cljs: #3 ready!
:cljs/quit
drops you back down to the clj repl. so you can switch between the runtimes if needed
What might the error messages above indicate? I've tried googling.
Easier to read.
These errors happened after I did git clean -fdx
and reinstalled d3
through npm.
I was able to lein shadow watch app
but I still get errors in the console. Anyways, if this is unrelated to shadow-cljs I'll try to google more myself š
the regenerator thing is a npm problem. you basically need to (:require ["regenerator-runtime/runtime"])
somewhere before you require the npm lib causing the problem
I guess it was really old š
Thanks for your help
My version 2.12.1
seems to be from April last year. I'll try upgrading.
Iām trying to run shadow-cljs
in embedded mode from a build.clj
.
Hereās what Iām running, I arrived at this by digging around the https://shadow-cljs.github.io/docs/UsersGuide.html#embedded of the docs, as well as https://github.com/thheller/shadow-cljs/issues/490.
(shadow.cljs.devtools.server/start!)
(shadow.cljs.devtools.api/compile*
{:target :browser
:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"
:main "hello-world.core"}
{})
ā¦Running clj -M build.clj
, I get a error:
Jan 27, 2022 9:45:35 AM io.undertow.Undertow start
INFO: starting server: Undertow - 2.2.4.Final
Jan 27, 2022 9:45:35 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.8.0.Final
Jan 27, 2022 9:45:35 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.0.Final
Jan 27, 2022 9:45:35 AM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.1.0.Final
shadow-cljs - server version: 2.16.12 running at
shadow-cljs - nREPL server started on port 54818
[null] Compiling ...
Syntax error (AssertionError) compiling at (build.clj:28:1).
Assert failed: (keyword? build-id)
Iād really like to be able to pass the build configuration right in my build.clj
. Does anyone see what Iām doing wrong?note that this is an invalid build config for :target :browser
. :main
does not apply there.
I switched the call to this:
(shadow.cljs.devtools.api/compile*
{:build-id :app
:target :browser
:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"}
{})
:output-to
also does nothing. :modules {:main {:entries [hello-world.core]}}
will create a main.js
in :output-dir
I strongly recommend keeping the build config in shadow-cljs.edn though. you lose a bunch of features if you don't
Thanks for working through this with me, itās compiling now! Iām noticing that it outputs a main.js
in my :ouput-dir
. Is that default/fixed behavior?
you should probably refer to the docs for questions as that https://shadow-cljs.github.io/docs/UsersGuide.html
rename it and you get a different file. all coming from your config, no default š
Iām kind of just messing around now, compile
caught my eye first. Whatās the different from release
?
release
creates a optimized release build. compile
creates an unoptimized development build, same as watch
just without the watch parts (no hot-reload, REPL, etc)
Ah okay, that was my guess. Iām toying around with my own REPL/reload setup for some custom pREPL tooling in Emacs. So Iām looking for a development build, but starting my own REPL server etc.
but for any kind of repl tooling regardless you must use watch
. compile
is not designed for it and will not work.
"will not work" is not exactly right. with your own REPL server it might work, it'll just be rather slow. compile has to load all caches from disk with each compile
watch
just loads it once and keeps it in memory making incremental compiles rather fast
Hmm yeah Iāve got a error when I connect to my REPL and try to evaluate:
:type java.lang.AssertionError,
:message \"Assert failed: (set? ns-roots)\", :at [shadow.build.cljs_hacks$shadow_find_ns_starts_with invokeStatic \"cljs_hacks.cljc\" 645]}],
Hereās my whole setup if youāre curious. I know this is unconventional and all this functionality is in shadow-cljs
⦠Iām just toying around and trying to replace the functionality with other standard Clojure tools for learning purposes.
(clojure.core.server/start-server
{:accept 'cljs.core.server/io-prepl
:address "127.0.0.1"
:port 6776
:name "build"
:args [:repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)]
:server-daemon false})
(org.httpkit.server/run-server
(compojure.core/routes
(compojure.route/files "/" {:root "public"}))
{:port 8000})
(cljs.build.api/build ;; or watch with path
{:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"
:main "hello-world.core"})
(println "Now connect through inf-clojure to port 6776.")
(println "Then, refresh the web page.")
Yeah, unconventional, like I said! I was just trying to replicate a really minimal ClojureScript compilation setup. This was working well with the code below:
(clojure.core.server/start-server
{:accept 'cljs.core.server/io-prepl
:address "127.0.0.1"
:port 6776
:name "build"
:args [:repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)]
:server-daemon false})
(org.httpkit.server/run-server
(compojure.core/routes
(compojure.route/files "/" {:root "public"}))
{:port 8000})
(cljs.build.api/build ;; or watch with path
{:output-dir "public/js"
:output-to "public/js/main.js"
:asset-path "js"
:main "hello-world.core"})
ā¦but I canāt for the life of me properly get cljs.build.api/build
to find my npm dependencies. shadow-cljs
is so, so good at that, I was hoping thereād be an easy way to just āswap outā those compile calls.
you can just set :prepl {12345 :app}
and that will give a a prepl on port 12345 for build :app
(all in shadow-cljs.edn of course)
Yeah, thatās a great feature. Iām really just experimenting, but I would say my goal is to see how I can leverage popular Clojure tools (httpkit, clojure.core.server, cljs.build.api) to āmix and matchā the behavior of my development experience.
well then shadow-cljs is probably not the right choice for you. it is a build tool already, not a toolkit to build a build tool.
it replaces basically all of the default build tooling, so anything trying to use that won't work either
Yeah I understand, I appreciate you being straightforward with me. I really admire the experience youāve built with shadow-cljs, and Iām sure Iāll end up using it as youāve intended for a real project!