Normally, Clojure source files are named (for example) foo.clj, and Clojurescript source files are named foo.cljs. My impression is that in Clojure versions >= 1.7, I can name a file foo.cljc if I want it to be available for loading with require
or use
both from Clojure and Clojurescript.
Is this correct? It seems to be implicit in the primary documentation pages on Using cljc and reader conditions, but as far as I can see it's never explicitly stated.
This is not a question about using reader conditionals to specify alternate code for running in Clojure and Clojurescript; it's more fundamental. For example, I have a source file that contains code that's completely generic: It will run in both Clojure and Clojurescript unchanged. Can I assume that by naming it with ".cljc", require
will always find it from inside both Clojure and Clojurescript (assuming it's named correctly, is in the correct location, etc.)?
[I'm pretty sure that I'm right, but I'm not certain, and I thought it would be worth having the answer documented here if I'm correct.]