Fork me on GitHub
#clojurescript
<
2021-06-28
>
javi09:06:06

Hi , in clj or cljs extra data readers are loaded from a data-readers.clj file at the root. For example in https://github.com/weavejester/hashp How would I go about adding those same readers in self-hosted cljs? I have found register-tag-parser! in reader but that seems to only apply when (reader/read-string {:some-k "some val"}) My case is in a live editor sending render of components to different divs based on the reader tag.

#r1 [a-com opts-1]
#r2 [a-com opts-2]
thanks in advance

thheller10:06:00

@fj.abanses pretty sure the self-hosted compiler uses this binding https://github.com/clojure/clojurescript/blob/017ce8812d9b73f5df076b20e818e0ae90b90812/src/main/clojure/cljs/tagged_literals.cljc#L87, so you can probably just bind that when you invoke the compiler? maybe the compile functions also take that as an arg?

javi10:06:25

thanks for the pointer @thheller , i am looking into it at the moment.

javi10:06:45

@thheller many thanks. A first quick test shows that the approach works. <using shadow-cljs here>

(defn eval-str [source cb]
  (binding [*cljs-data-readers* (merge *cljs-data-readers* {'r1 (fn [form] (str form))})]
    (cljs/eval-str
    c-state
    source
    "[test]"
    {:eval cljs/js-eval
     :load (partial boot/load c-state)
     :ns   (symbol project-ns)}
    cb)))

West19:06:33

Does anyone here have experience publishing projects to the npm repository?

thheller19:06:15

you mean like the shadow-cljs npm package? 😛

West22:06:44

The reason I ask is because I’m trying to automate versioning, releasing, and publishing to npm via circleci. It looks like you’ve automated building and testing @thheller. Do you do these steps manually?

thheller06:06:21

I do things manually. takes 5sec max. setting something up probably takes hours 😉

Asko Nōmm22:06:30

I think you can just connect a Github repository to NPM as well, and it would update the NPM as soon as a new tag is released on Github.

😮 3