(def transit-write-opts
(try
(require '[cognitect.transit])
(when-some [ns (find-ns 'cognitect.transit)]
(let [write-handler @(ns-resolve ns 'write-handler)
write-handler-map @(ns-resolve ns 'write-handler-map)]
{:handlers
(write-handler-map
{JSValue
(write-handler
(fn [_] "cljs/js")
(fn [js] (.val ^JSValue js)))
Pattern
(write-handler
(fn [_] "cljs/regex")
(fn [pat] (.pattern ^Pattern pat)))})}))
(catch Throwable t
nil)))