Hi! I have a question about tooling, and specifically starting the REPL. I work with Emacs and Cider, and before I added CLJS to my project I was starting a regular (I assume) Clojure REPL via the Cider jack-in command. Now, I followed the full-stack workflow post from Thomas Heller (https://code.thheller.com/blog/shadow-cljs/2024/10/18/fullstack-cljs-workflow-with-shadow-cljs.html), and that got me starting a separate shadow-cljs REPL in a terminal, and then connecting to it from Emacs. I’m a beginner at Clojure, so I’m not sure about the differences between the two. I assume it’s not problematic to just use the Clojure REPL started via shadow-cljs? Is there a way to make it so that this REPL is the one started via Cider jack in? Or is there another approach that’s a best practice? Grateful for any insights! 🙏
I ended up running the REPL from the command line with clj -M -m shadow.cljs.devtools.cli clj-repl and connecting to it from CIDER. Then I switch to the cljs repl with (shadow.cljs.devtools.api/repl :frontend) as needed. Happy with this workflow!
I should also say that I tried to just load the shadow-cljs API namespace into the normal Clojure REPL that starts via jacking in in Cider, but this forced me to add a dependency to my deps.edn (`commons-codec/commons-codec`), which makes me feel like I might run into some other missing dependencies down the line.
jack in is pretty much the same as starting the REPL via shadow-cljs. the only thing that may be different is how dependencies are declared/used. if you follow the described setup they should all be in deps.edn, so dunno why anything would be missing.
jack in is nothing else than cider starting the JVM process for you and then connecting the REPL
instead of you starting the JVM process manually (via shadow-cljs) and then connecting
@thheller Thank you! That makes sense. I was able to trace this behaviour in the shadow-cljs code, too: when you run clj -M -m shadow.cljs.devtools.cli clj-repl, it ends up executing clojure.main/repl in the end.
thats not the REPL used when your editor connects, but yeah close enough
There is also a jack in command for cljs: M-x cider-jack-in-cljs.
And in theory, you can M-x cider-jack-in-clj&cljs to start two REPLs in one go, but it's tricky to get it work for my project somehow. So I just start them by running M-x cider-jack-in-clj and M-x cider-jack-in-cljs separately.
Hi folks! So... a question:
I don't suppose there's a workaround for the limitation of being unable to run multiple ClojureScript projects in the same runtime, in watch mode, right?
The context is: I'm making editor plug-ins with ClojureScript. Unfortunately, this means if I am developing two different plug-ins at the same time (`shadow-cljs watch`, basically) they conflict with each other because of the Closure compiler, some globals that get defined, etc. I decided to check the ESM target to see if I could bypass this, but it doesn't seem so (it just gives me a Namespace "cljs.core" already declared.).
So I'm just checking here if someone was able to do some... magic, maybe with some external tools... to circumvent this.
shadow-cljs can watch multi targets at the same time, have you tried that?
These are different projects, so that won't work for me...
Although I think I found a VERY HACKY way. I'll test it better and check if it works
I would like to test http://automerge.org. But I get this error:
Failed to inspect file
/p/localmo.de/node_modules/@automerge/automerge-repo/dist/index.js
Errors encountered while trying to parse file
/p/localmo.de/node_modules/@automerge/automerge-repo/dist/index.js
{:line 35, :column 9, :message "'from' expected"}
Any ideas what is causing the error?https://clojurians.slack.com/archives/C6N245JGG/p1736283925872849
Thank you, @macroz I have added the following into my shadowcljs.edn:
:js-options {:js-provider :external
:external-index "public/js/external-index.js"}
But now I get:
hook.js:608 Failed to load shadow.js.shim.module$react.js ReferenceError: shadow$bridge is not defined
at eval (shadow.js.shim.module$react.js:3:41)
at eval (<anonymous>)
at goog.globalEval (main.js:456:11)
The shadow-cljs documentation mentions I need to use webpack or something. I have never used webpack or anything like that. Can you point me to an example of a shadow-cljs project with :js-provider :external ?Or could / should I use Automerge from a CDN instead?
There are some older threads with that error also. Sorry that I don't have a direct answer 🤷
No problem, I will try Yjs instead.
Does anyone have a sample project that uses ExpressJS and its middlewares and EJS templates with the appcode in Clojurescript?