Fork me on GitHub
#polylith
<
2023-05-05
>
eval-on-point12:05:34

I am reading up on some of the Clojurescript discussion (currently trying to find a solution for our project) and am starting to get a little confused about workspaces as a concept. If you have multiple workspaces, how would you share code between them? We have code that is shared across multiple deployables, and my impression was that our deployables mapped to Polylith Projects, not workspaces.

🙌 4
tengstrand12:05:46

Deployables will still live in projects. Then our idea is to allow having several workspaces live at the root of the repository, e.g.:

my-repo
  backend
    components
      component1
    bases
    projects
      project1
  frontend
    components
    bases
    projects
      project2
  root.edn
Each artifact will be built from a project, same as today. If we let all cljc code live in the backend as components, then component1 can be used from frontend/projects/project2/deps.edn by using the path "../../../backend/components/component1". At the top of my-repo we can have a root.edn that specifies the alias for backend as e.g. b and then when we run the info command from the frontend workspace, it will display component1 as b/component1 .

eval-on-point12:05:06

Oh thanks that clears it up for me. At least until I start trying to actually hammer this out. We currently have a base that serves static http files, and our cljs projects use that base to serve the compiled clojurescript and other resources. In this new model, we will have 1 frontend base per clojurescript build, which uses our "static http server" from the backend components to serve them.

2
eval-on-point13:05:37

Thinking about it a little more, it makes sense to me that the "frontend" projects ultimately just create a set of static resources. Then, there will be a backend project which bundles up the frontend static resources to serve

tengstrand13:05:28

Does the suggested structure feel natural to you? Would you split up the frontend and backend into two separate workspaces, as we suggest?

eval-on-point13:05:04

It is all still percolating up in my head but I might try it all with just one workspace as a first pass. The important insight I think I have just achieved is that your clojurescript projects should probably just "build" a set of static resources. Serving them is of course the responsibility of some clojure project. You can probably just have a single "static http server" project and deploy multiple instances of it with your clojurescript project dirs mounted to it

eval-on-point13:05:35

Single workspace vs multiple workspaces is likely just a function of developer ergonomics which I am definitely not qualified to comment on at the moment lol

eval-on-point13:05:39

As a point of reference, we already have some unusual polylith projects that don't use Clojure code. They still just sit inside the same workspace. Some, such as our Docker base images, don't even have any code at all besides a docker file. So, we may be abusing the system already

❤️ 2
tengstrand14:05:16

Ha ha! Feel free to "abuse", as long as it solves your problems! The reason for keeping clj and cljs code separated, is to simplify the output of some commands, like the deps command (clj and cljs code can't depend on each other anyway).

👍 2
avocade14:05:23

Really looking forward to when the poly tool will support cljs fully, so we can divide our repo into proper frontend and backend workspaces! Currently just fails utterly, eg in furkan's very nice polylith-multi-ws-experiment lib 😄 Would be good to have some more clarity around where to place the "shared" files (`cljc`), but maybe there simply is no obvious place (a separate workspace sounds tedious) and it should just belong in the backend as you've suggested before @U1G0HH87L – but that does tickle the perfectionist nerve somewhat… 🙂

12:08:32

If you decide to let cljc code live in the backend, then you can have some level of separation by letting the cljc code live in src/cljc and clj in src/clj within each brick.

avocade14:09:47

Yeah maybe. How are things coming along with the cljs additions otherwise? 🙂

Nick20:05:11

Hey All -- I was curious if anyone is using Clerk inside polylith? If so, do you have any recommendations for how and where you put the notebooks? For example do you create a "notebooks" directory in every component, or a base that has all the notebooks, or something else?

eval-on-point20:05:51

are you building the notebooks and deploying them somewhere, or are they mostly developer documentation? if it is mostly for development, I would place them in the development folder unless they logically fell into a specific component

Nick20:05:05

I'm just getting started, but I am thinking it will be mostly developer documentation. We end up having very large comment blocks in each of our components that are poor man versions of a clerk notebook. We often jack-in to a specific component to develop in isolation as well, so I could be persuaded to keep them in the components . When giving it a try, I followed the tutorial to launch Clerk on localhost:7777 from a "launch.clj" namespace. Then within that call clerk-show! on the specific notebooks within the component. It feels a bit janky, and that's why I am reaching out to see if you guys have some better ideas.

Oliver Marks09:05:24

I have been putting them in development inside a folder called notebooks, mainly so you have access to all components and bases. but also curious what others do