Fork me on GitHub

Hello! I want to do a quick poll: On your fullstack (frontend + backend) projects where frontend is a spa built with shadow-cljs, do you create: a) a repo for each project (like project-web, project-service) b) a repo with a subdirectory for each project (like project/{web,service}) c) a repo for both projecs on the same structure, with backend and frontend code coexisting under same src/ (maybe with/in different namespaces) If the answer is (c) how do you do this? Also, how do you share common cljc code between the frontend and the backend? Foremost and most important, how do you make a project that has both a normal deps.edn project for backend and a shadow-cljs.edn project for frontend?


I do both b) and c), but in c) I use Leiningen and not deps.edn. The CLJC is shared. Both project.clj and shadow-cljs.edn reside in the root directory, each with the correct src settings. The settings don't overlap much.


Where do you run into a problem?


I haven't (yet) because I so far used option (b). I'm just making a poll to see what most people use, and to gain ideas whether it is possible to fire a single repl to host both the frontend and the backend somehow for option (c) 🙂


You would have two REPLs, one for CLJ and one for CLJS.


Yes I suppose that part is inevitable, given where each part runs


I just switched to this setup. Previously I could launch both together in Emacs/CIDER with Leiningen & Figwheel classic, but I haven't gotten the setup to work with Leiningen and Shadow-CLJS so I start one in terminal and other in Emacs/CIDER.


I'm just trying to establish a workflow where I won't need multiple editors open


You can have each build tool usually in watch mode in a terminal somewhere and use one editor. In case of Emacs/CIDER you should be able to have both in one editor. And Emacs can of course have terminals in it too. The advantage of the "proper support" is that you can use all the bells and whistles so jump to source (without LSP etc.)


But YMMV depending on the editor.


I'm using neovim + olical/conjure for repl + clojure-lsp for lsp


I think this channel is perhaps wrong for this question, it is not at all related to Shadow-CLJS.


Yeah I posted it here because I believe that the biggest challenge is having shadow-cljs play along inside a normal clj repl somehow


I tend to start Shadow-CLJS either from terminal or a dedicated REPL for it.


damn that section opens up a LOT of possibilities


Actually this gives me a direction on how I could make (c) viable


Since the code I run in the Shadow-CLJS REPL is intended for the browser, I would anyway want it to be separate.


Depending on the source file (CLJ or CLJS), CIDER knows to pick the correct open REPL


Yes that is exactly how I wanna configure mine


according to the currently focused window


This is with the disclaimer that I mentioned previously that my setup worked better with Leiningen+Figwheel and now something prevents me from launching Leiningen+Shadow-CLJS at the same time, but haven't had time to investigate really. I hardly ever use the browser REPL, I often rather print to the browser.


Something related to CIDER though, not Shadow-CLJS issue.


We have frontend in one folder, on the same level as many folders for the backend code in polylith. I run neovim and conjure, but many instances. I don't even use buffers, but every file is managed by wm. The editor knows what repl to pick up by traversing the tree up, looking for the .nrepl, which hits the frontend shadow-cljs repl before it goes up the the repository root, where the clj repl port is written to


Excuse my ignorance, what do you mean by 'wm'?


Window manager


As in linux window manager?


Yes, I use the tiling i3, which is much like you would have with split view of vim buffers, but works then for everything


Ah, I use bspwm myself, but I still prefer managing my project's files inside vim panes