cognitect / transit-cljs

Transit for ClojureScript
http://transit-format.org
Apache License 2.0
323 stars 20 forks source link

:transform is not implemented on writer #48

Closed wilkerlucio closed 5 years ago

wilkerlucio commented 5 years ago

I was trying to use the :transform feature from the writer but seems like it's not implemented in the CLJS version, this is an example code using Clojure transit (this works):

(let [x (with-meta [:a] {:foo "bar"})
        baos (ByteArrayOutputStream.)
        w    (transit/writer baos :json {:transform transit/write-meta})
        _    (transit/write w x)
        ret  (.toString baos)]
    (.reset baos)
    ret)
=> "[\"~#with-meta\",[[\"~:a\"],[\"^ \",\"~:foo\",\"bar\"]]]"

But doing a similar run in CLJS yields:

(-> (transit/writer :json {:transform transit/write-meta}) 
      (transit/write (with-meta [:a] {:foo "data"})))
=> "[\"~:a\"]"

The docs on CLJS suggest this should work. So I guess it was copied the docs but never implemented?

wilkerlucio commented 5 years ago

I just noticed my transit-js lib was outdated, forcing it to the latest fixed the issue.

awb99 commented 4 years ago

I just came into the same issue. Something is broken in the CI / build system. the latest transit-cljs artefact has an old transit-js dependency. This should not happen. As it is now, write-meta will only work if additionally the latest transit-js is added as dependency. I think CI is broken, because source code in github and artefacts in maven are different version numbers.

swannodette commented 4 years ago

@awb99 more information would be helpful - what is the discrepancy in the versions? The pom.xml and project.clj are of course pointing at the latest.