I opened the ticket since I wanted to to be able to have conditional requires in ClojureScript.
In Clojure you can just call (when condition (require 'some.ns) ...) at runtime. This is actually used in quite a lot of places and very useful. This however is not possible in ClojureScript due to the limitations imposed by the Closure Compiler. All requires are completely static and cannot be modified. Unlike Clojure on the JVM, ClojureScript does run on a variety of different platforms. It may run in the browser, node, react native etc. In my case I needed to exclude a require since including it broke the build for nodejs. It will be fairly common that you'll want to re-use your React components from the Client for a server-side render (or elsewhere).
One such package would be CodeMirror. It does not run in node due to heavy DOM interop. It is not required for server-side render. It should just not be included.
Other "solutions" for this problem I have seen include either using a global variable and assigning that somewhere outside the build itself (eg. via :preamble) or using different source paths to include empty dummy namespaces. Both options are clunky to use and not always feasible to do. Sometimes you'll just might just need to omit one function call. Another option that I relied on heavily previously was using a :closure-defines variable and hope that the Closure Compiler would be able to eliminate the unusued code. This works to a certain extent but is also not 100% reliable and you'll still end up compiling everything.
(ns my.cool.component
(:require
[reagent.core :as r]
#?@(:node []
:cljs [["codemirror" :as cm]])))
I implemented this feature in shadow-cljs and just set :compiler-options {:reader-features #{:node}} for the node build. Simple. For Clojure or maybe even the newer cljs.main a command line option/system property could be used.
The features only apply when reading ClojureScript since :clj only has one runtime: the JVM. Clojure can already do dynamic require so my use-case doesn't apply at all. Clojure happily ignores the unknown features when reading so they don't interfere with anything. Personally I didn't need any boolean feature combinations yet. Although my use is rather limited to 3 uses at the moment.
Self-hosted macros are hairy at the moment but could actually become simpler if they had their own :read-cond feature to begin with.
The question whether the :reader-features should be enabled in .cljs files came up in a discussion with Kevin Lynaghk and my argument was that it might be useful but would probably break tools and the default CLJS compiler so I opted to staying with .cljc files.
In the case of shadow-cljs I didn't need to change the compiler at all since I already handle the reader. The change was trivial though and should be equally simple for ClojureScript.