|
|
|
|
|
by masijo
560 days ago
|
|
I agree with your criticism but those "mistakes" sadly come with inheriting implementation details of the hosted environment. As far as I understand, ClojureScript couldn't workaround some JavaScript limitations regarding macros and thus had to go with `:require-macros`. A workaround is using Reader Conditionals (https://clojure.org/reference/reader#_reader_conditionals) and specifying platform differences where they matter, but it's awkward to say the least. What most projects do is to separate "common" namespaces and use the `.cljc` extension to indicate they're multi platform, and keep platform specific things in namespaces with `.clj`, `.cljs`, etc. |
|
This is exactly what I witnessed when finding the example above.
Out of frustration, I tried patching shadow-cljs one afternoon and was able to implement :refer :all as well as automatically generating :require-macros when needed to some extent, but I haven't put the time to make it work fully. I don't think this is a limitation caused by the lack of a Clojurescript compiler that can run in a Javascript runtime. In short, I don't think this is an essential limitation of the way the language is hosted within its target language, unlike things like Vars, which are not introspectable at runtime in js.