Fork me on GitHub
#polylith
<
2022-02-27
>
mindbender09:02:49

Can components depend on other components and how?

David Vujic09:02:42

Yes, I believe you can require a component just as with any other namespace. If I’m not mistaking, the components will know about each other because they are referenced in the project specific deps.edn (and the dev deps.edn). I found an example in the Polylith RealWorld repo: https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app/blob/master/components/article/src/clojure/realworld/article/core.clj#L5

mindbender09:02:24

Nice, thanks! That answers it.

👍 1
tengstrand07:02:57

Components only know about interfaces which is something all components “implements” by exposing at least one namespace, e.g. com.mycompany.invoicer.interface (`com.mycompany` is the top namespace in this example). Then other components can access invoicer by require:ing that interface namespace. Each project then decides which concrete component to include (maybe a component with the name invoicer or some other name, as long as it contains the namespace com.mycompany.invoicer.interface).

👍 1