Fork me on GitHub
#shadow-cljs
<
2022-12-21
>
agorgl18:12:00

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?

Macroz18:12:16

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.

Macroz18:12:48

Where do you run into a problem?

agorgl18:12:18

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) 🙂

Macroz18:12:07

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

agorgl18:12:38

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

Macroz18:12:02

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.

agorgl18:12:05

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

Macroz18:12:18

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.)

Macroz18:12:56

But YMMV depending on the editor.

agorgl18:12:30

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

Macroz18:12:40

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

agorgl18:12:29

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

Macroz18:12:23

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

agorgl18:12:11

damn that section opens up a LOT of possibilities

agorgl18:12:59

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

Macroz18:12:01

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

Macroz18:12:26

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

agorgl18:12:47

Yes that is exactly how I wanna configure mine

agorgl18:12:57

according to the currently focused window

Macroz18:12:01

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.

Macroz18:12:24

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

Hukka19:12:29

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

agorgl19:12:15

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

Hukka19:12:23

Window manager

agorgl19:12:36

As in linux window manager?

Hukka19:12:08

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

agorgl19:12:35

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