What are the best practices to follow when managing a full stack project using poly? I am specifically unsure about the cljs code. Does anyone here have experience with that? How do you structure ? Where do you keep components and utils namespaces?
We have a Polylith component called ui (shocking, right? 😂) that contains a large chunk of dumb UI components with their styles; there is no business logic there. We have several other components that cover more isolated UI areas with more business logic involved, such as a component for our text editor. As you can imagine, it is quite large inside but has a very small interface exposing a renderer function to render a rich text editor and several other helper functions.
Apart from the front end, some services on our back end have to run on a Node.js environment. We mix clj and cljs implementations with a cljc interface in the components shared between our Java and Node services. For example, we have a component called database, which wraps functions we use to make calls to our SQL database. Each clj and cljs implementation files have its own implementations based on the runtime environment, using completely different libraries. However, there is one contract in the cljc file. The file structure looks like this:
â–¼ database/.../src
▶︎ core.clj
▶︎ core.cljs
▶︎ ifc.cljc
You can look at my attempt at combining backend and frontend realworld examples in one single Polylith workspace. I created https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app/tree/cljs-frontend a while ago as an example so we can use it while developing CLJS support for the poly tool.We think of components and bases as equal units of the codebase with no hierarchy or organisation. The Polylith workspace is where all that code lives, ready to be used in a project or referenced by another component or base. The hierarchies and structure organically happen when we put those components together as the need arises and when we create new services to deploy due to other requirements.
We use Polylith structure in our clj-cljs mix project, however, without poly tool support. We don't do anything special. We have all possible combinations in our components. Some are pure clj or cljs, some are mix of clj+cljs with a cljc interface. We also have a couple of pure cljc components that have shared code.
Interesting, do you keep the UI components (not poly comps) in a separate poly component, or is it a part of the frontend base? Curious about the project structure you use. Would appreciate if you could share a rough picture of it.
The poly tool only supports clj+cljc at the moment, but I know that some people choose to structure even the cljs code as components, even though there is no poly support for it.