Fork me on GitHub

@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!

👀 1

:cljs/quit drops you back down to the clj repl. so you can switch between the runtimes if needed

👍 1
Nom Nom Mousse17:01:25

What might the error messages above indicate? I've tried googling.

Nom Nom Mousse17:01:02

Easier to read.

Nom Nom Mousse17:01:40

These errors happened after I did git clean -fdx and reinstalled d3 through npm.


from your messages in #clojurescript I assume you figured it out?

Nom Nom Mousse17:01:07

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


or upgrade shadow-cljs in case you are on a really old version

Nom Nom Mousse17:01:51

I guess it was really old 😄

Nom Nom Mousse17:01:00

Thanks for your help

Nom Nom Mousse17:01:51

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 of the docs, as well as


 {: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?


:build-id :app or something needs to be in that map


note that this is an invalid build config for :target :browser. :main does not apply there.


you maybe want to configure your logging so that the undertow/xnio stuff goes away


Agreed that’s a little too verbose


I switched the call to this:

 {:build-id   :app
  :target     :browser
  :output-dir "public/js"
  :output-to  "public/js/main.js"
  :asset-path "js"}


still invalid. missing :modules


: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?


(As I’ve omiitted the :output-to, as you mentioned)


you should probably refer to the docs for questions as that


the :main module produces main.js in :output-dir


Yep I see that now


rename it and you get a different file. all coming from your config, no default 😛


That’s great, really appreciate your quick response @thheller, as usual.


why compile though? watch and release are the common ones, compile is kinda rare?


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.


I’ll pass it along if I get something cool!


shadow-cljs has built in prepl support in case you didn't know


prepl sucks so I wouldn't recommend it though 😉


but for any kind of repl tooling regardless you must use watch. compile is not designed for it and will not work.


This is such great info, thank you!


"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_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.

 {:accept        'cljs.core.server/io-prepl
  :address       ""
  :port          6776
  :name          "build"
  :args          [:repl-env (weasel.repl.websocket/repl-env :ip "" :port 9001)]
  :server-daemon false})

  (compojure.route/files "/" {:root "public"}))
 {:port 8000})

( ;; 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.")


uhm you are trying to use weasel with shadow-cljs? that'll not work


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:

 {:accept        'cljs.core.server/io-prepl
  :address       ""
  :port          6776
  :name          "build"
  :args          [:repl-env (weasel.repl.websocket/repl-env :ip "" :port 9001)]
  :server-daemon false})

  (compojure.route/files "/" {:root "public"}))
 {:port 8000})

( ;; or watch with path
 {:output-dir   "public/js"
  :output-to    "public/js/main.js"
  :asset-path   "js"
  :main         "hello-world.core"})


what is your intended end goal here?


…but I can’t for the life of me properly get 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, 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!


If only :npm-deps on the ClojureScript compiler would work properly…


if you explain what you are trying to do I can maybe provide some pointers. shadow-cljs is pretty flexible, so it should be possible to just disable the parts you don't want to use but keep the rest


but that being said it is built to do exactly what it does. everything else is asking for trouble 😉