beginners

valerauko 2026-02-20T13:08:01.258949Z

Is it possible / recommended to have the same filename in cljc and platform specific? Like having a routes.cljc and a routes.cljs both having (ns my-app.routes) in them

Harold 2026-02-20T13:28:04.963489Z

Anything is possible, but I wouldn't do that. A thing to think about is what the namespace names will turn out to be.

2026-02-20T13:42:31.228909Z

I would also suggest not to do it. It should work (like a compiler will allow it) but I assume that the order that it loads depends on which compiler you use/isn't defined in a spec, so you might get confusing results. If I remember right generally it looks for the specific language first and then the CLJC (but don't quote me on that). In any case, I'd suggest if you need something that spans both clj and cljs, use a .cljc file and use the #? reader macro to either have the code inline or require it conditionally, with a different namespace name

Alex Miller (Clojure team) 2026-02-20T17:17:04.866689Z

The platform specific file is used if found. Will fall back to cljc if not found. Usually you will only have both if one dialect is too hard to platformize in cljc and it's just easier to provide a replacement

valerauko 2026-02-21T00:39:48.504789Z

Thanks, I'll keep that in mind! It was along the lines of providing a public api in a cljc file and the platform-specific files would "override" those. I realize this can be done just fine with protocols though