clojurescript

2025-01-09T13:52:37.146209Z

Anyone have any ideas why requiring cljs.analyzer changes how java.time.Instant is printed? Details in thread.

2025-01-09T13:52:47.543899Z

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=>

zy C 2025-01-09T14:03:58.847469Z

cljs.analyzer -> cljs.tagged-literals -> cljs.instant

2025-01-09T14:10:09.647389Z

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?

👍 1
2025-01-09T14:12:15.952409Z

Maybe it was not supposed to be a library in the first place, but was used like it anyway?

2025-01-09T14:32:05.474389Z

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.

p-himik 2025-01-09T18:12:49.590199Z

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.

2025-01-09T18:53:42.218189Z

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.

p-himik 2025-01-09T19:06:45.682919Z

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