Fork me on GitHub
#clojurescript
<
2024-01-09
>
Nundrum16:01:30

Can someone point me to guidance on how to make a CLJS library? I've pulled together some functions to use polybooljs along with others to make working on polygons and SVG more convenient. Putting that into something re-usable would be great! I just can't figure out how.

p-himik16:01:20

Will it be used only from CLJS or also from JS?

Nundrum16:01:35

Only from CLJS. I figure JS devs else would just use polybooljs directly.

p-himik16:01:46

I'd choose the lazy route and put only deps.edn in there with an instruction in the README to install any necessary NPM packages. It's not different from a CLJ lib that depends on some native library.

Nundrum14:01:51

Thanks for that! Had a little bit to figure out since I hadn't used tools.deps for packaging before. But I got it installed into my local ~/.m2 and used it in my main project last night.

p-himik14:01:23

What do you mean by "installed into ~/.m2"? You almost never have to touch that dir yourself.

Nundrum15:01:41

Just that. Installed it there with the build api's installso I could reference it in shadow-cljs.edn and test that it worked. A nice step before writing docs and uploading to github/clojars.

p-himik15:01:29

Ah, right, gotcha. BTW, if a tools.deps-based dep is in a public Git repository and doesn't need any compilation then it doesn't even have to be uploaded to Clojars since tools.deps has native support for Git deps.

Nundrum15:01:17

Good to know 🙂 That'll save some hassle. Right now I'm struggling with codox/quickdoc. Neither one will include the docstring from ns in the output. I'll probably drop a question later today if I can't figure out why.

p-himik15:01:14

Just in case - how do you specify the docstring on a namespace?

Nundrum15:01:15

(ns cljs-polys-etc.polys                                                                                                                                                                          
  "Functions for working with polygons in SVG. This library requires `polybooljs` to work. "                                                                                                      
  (:require                                                                                                                                                                                       
    [polybooljs :as pbjs]))    

Nundrum15:01:02

A Conjure keyword lookup on the namespace shows me the docstring, so I think that's OK.

p-himik15:01:27

Yeah, that's fine. Interesting, maybe it has something to do with the ns being a CLJS one.