Allow clj->js to preserve namespaces

Description

Original issue
https://dev.clojure.org/jira/browse/CLJS-536

Keypoints from CLJS-536

  • IEncodeJS is powerfull, but for keywords, can break other libreries that expect trim-ns behavior (Le Wang)

  • With the introduction of specs, the namespaced keywords are being used more and more. This issue prevents streamlined edn->json->edn transformation. I think it should be reopened. IMO the 'lossy' method should never be a default one. (Jozef Wagner)

  • Should be possible do this without break existing code and using kwargs (Paulus Esterhazy)

An use example can be `(clj->js {:foo/bar 33} :keyword-fn #(.-fqn %)) ;=> #js {:foo/bar 33}`

PS: key->js should use key>js method, but I keep it with clj>js to avoid break things (it should be another bug?!).

Environment

None

Activity

Show:
Mike Fikes
November 30, 2017, 1:53 PM

Looks like we are already set up for the opposite direction:

Docstring should be updated for :keyword-fn.

Given that this might slow down clj->js, perhaps benchmarks should be added to cljs.benchmark-runner to show that there aren't huge perf regressions.

Completed

Assignee

David Nolen

Reporter

Enzzo Cavallo

Labels

Approval

Accepted

Patch

Code and Test