Anyone have any ideas why requiring cljs.analyzer changes how java.time.Instant is printed? Details in thread.
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.11.60"}}}'
Clojure 1.11.3
user=> (import '[java.time Instant])
java.time.Instant
user=> (java.time.Instant/now)
#object[java.time.Instant 0x56ccd751 "2025-01-09T13:50:48.958890Z"]
user=> (require 'cljs.analyzer)
nil
user=> (java.time.Instant/now)
#inst "2025-01-09T13:51:01.185792000-00:00"
user=>
cljs.analyzer -> cljs.tagged-literals -> cljs.instant
There it is. Thank you. I'll say it has caused quite a bit of problems for us. Both Snitch and ShadowCLJS require this namespace, which in turn overwrites our own literals. Am I wrong in thinking that it is not a good approach for libraries to manipulate globals in this way?
Maybe it was not supposed to be a library in the first place, but was used like it anyway?
In short, our app reads and writes #time/instant perfectly fine, until cljs.instant is required transitively like demonstrated above by some dev-tooling like Snitch or ShadowCLJS. At that point, java.time.Instant is written as #inst , which in turn is read as java.util.Date - breaking in fun and interesting ways, since it breaks as part of general conveyance, being moved between queues, for instance.
Wouldn't the problem be solved by not using CLJS dev tooling with your app's process? Unless building CLJS is a part of your app's workflow, it's a very common recommendation to fully separate frontend and backend classpaths.
We were initially using Launchpad and its shadow-cljs support. That was the first time this issue bit us. We have since split the shadow-cljs build out. The second time was when using Snitch, which is indeed intended to be used in the backend app process, which just makes it a no-go, unfortunately.
The original issue is https://clojure.atlassian.net/browse/CLJS-3291 which got fixed by @mfikes, so maybe he can chime in. A somewhat relevant issue: https://ask.clojure.org/index.php/13362/cant-inst-values-metadata-error-supported-class-java-instant