cider
cider copied to clipboard
Requesting more details in `cider-jack-in-clj&cljs` (for setting up "full stack" clojure+clojurescript environment)
Hi, It would be great if there was a section on the ClojureScript docs about setting up a "fullstack" cider environment for clojure and clojurescript. I was able to make it work with figwheel-main and tools.deps, but I know it is possible to do so with other tools combinations like shadow-cljs and lein.
I read both cider.mx and figwheel-main docs and couldn't figure out how to setup a project such I could use cider-jack-in-clj&cljs. I wanted to run some clojure API plus a cljs client. The final solution that I found involved using a ring-middleware for the API, but I think after digging around I would be able to do it with an stand-alone clojure server... (maybe,,, :-).
In the process of attempting this, I followed some pointers into other documentation sites including nrepl's, lambda island repl site and dirac's repl diagrams.
Before reading this I wasn't sure what was going on with the "fullstack" setup... I slowly began to unravel what (I think) was going on...
- I wasn't sure if I needed an nREPL process for clj and another for cljs, but now I think we only need one since the single nREPL server can be setup to handle both environments (piggieback involved in "routing" to cljs).
- I tried to setup a script manually stitching info from figwheel-main and cider site, but since I was trying to setup two nREPLs servers from the same script, I was confused and I wasn't able to make it work.
- I wanted to somehow configure which port the nREPL server would be running on, but figwheel-main does not allow that as far as I can tell... Later I found that nrepl.cmdline is involved on the processes (not mention in either doc sites), and is the code that generates that .nrepl-port file on the root of the project.
- In the end I found and forked a repo that was setup properly , ran
cider-jack-in-clj&cljscommand, and things just worked! I'm pretty sure the difference with everything that I tried before was a proper setup of .dir-locals.el, which is mentioned in different places in cider.mx docs but I did not draw the picture from the dots.
Finally, here are some quasi monologues I followed in the process of learning all this: https://clojurians.slack.com/archives/C0617A8PQ/p1580935503106500 https://clojurians.slack.com/archives/CALJ3BFLP/p1580899631068000
I'll extend the docs when I can, but here a few quick answers.
I wasn't sure if I needed an nREPL process for clj and another for cljs, but now I think we only need one since the single nREPL server can be setup to handle both environments (piggieback involved in "routing" to cljs).
CIDER uses a single nREPL process to host both the Clojure and ClojureScript REPLs.
I wanted to somehow configure which port the nREPL server would be running on, but figwheel-main does not allow that as far as I can tell... Later I found that nrepl.cmdline is involved on the processes (not mention in either doc sites), and is the code that generates that .nrepl-port file on the root of the project.
That's documented on nrepl.org, but I guess it won't hurt to add some pointers here as well.
In the end I found and forked a repo that was setup properly , ran cider-jack-in-clj&cljs command, and things just worked! I'm pretty sure the difference with everything that I tried before was a proper setup of .dir-locals.el, which is mentioned in different places in cider.mx docs but I did not draw the picture from the dots.
If you have any suggestions how to improve the .dir-locals.el instructions, please let me know.
One suggestion could be to have a single place were every cider setting that one would normally want to to put .dir-locals.el would be documented (I'm pretty sure at the moment example .dir-locals.el settings are sprinkled across pages).
Another: for something like cider-jack-in-clj&cljs, maybe there could be a sort of canonical example repo with a couple example configurations, similar to the one I found. NOTE: I tried the figwheel-main template (with deps/clj -A:new) but I'm pretty sure it doesn't work out of the box with clj+cljs.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!