Fork me on GitHub

I need input on how should be approached. TL;DR: the recently-introduced :as-alias option in require does not cause a namespace to be loaded and therefore does not introduce a dependency from the requiring namespace on the namespace being used in :as-alias. poly doesn't recognize :as-alias so it thinks any such requires are full ns loads and full dependencies. At work, this surfaces as a circular dependency complaint (which it isn't). I have a fork of Polylith that modifies the namespaces_from_disk.clj file so it essentially ignores such namespaces. That isn't quite the right solution, because it prevents poly from checking that you're only referring to an interface (if the ns is in another brick) -- it does, however, stop poly treating it as a fully-loaded ns and therefore it does not recursively check for dependencies. I think a complete solution would be to annotate each ns symbol with metadata, indicating whether it's a full load or just an alias -- but that would a) propagate through a lot of poly's namespace checking since different rules would have to apply in different places and b) any manipulation of the namespaces would need to preserve that metadata. Otherwise, poly would have to maintain parallel dependency trees -- one that represented the complete ns graph and one that included but stopped at :as-alias (although I suspect that still leaves open an edge around namespace A requiring namespace B which requires A :as-alias). So I think it's a hard problem to solve correctly. I can submit a PR of my "sledgehammer" fix, which is to ignore :as-alias dependencies (so you lose interface checking on them but otherwise everything else behaves "as expected").


I need to dig into this. I will be away this week, but will have a more time to look at it next week.


NP. It's hard. We have a workaround (in my fork) that we're using. And it's an edge case feature. I'm just not sure what the complete solution should be.

👍 1