This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-20
Channels
- # aleph (11)
- # announcements (3)
- # babashka (35)
- # babashka-sci-dev (28)
- # beginners (29)
- # calva (51)
- # cider (33)
- # clj-kondo (26)
- # clj-on-windows (1)
- # clojure (40)
- # clojure-austin (1)
- # clojure-europe (47)
- # clojure-nl (9)
- # clojure-norway (7)
- # clojure-uk (5)
- # clojurescript (69)
- # conjure (30)
- # cursive (7)
- # data-science (9)
- # datomic (2)
- # etaoin (10)
- # events (2)
- # fulcro (1)
- # graalvm (1)
- # gratitude (6)
- # helix (16)
- # honeysql (20)
- # hyperfiddle (14)
- # inf-clojure (2)
- # jobs (1)
- # jobs-discuss (12)
- # kaocha (9)
- # leiningen (2)
- # lsp (4)
- # malli (8)
- # music (9)
- # off-topic (12)
- # pathom (10)
- # portal (14)
- # practicalli (15)
- # re-frame (27)
- # reitit (7)
- # remote-jobs (4)
- # sci (37)
- # shadow-cljs (16)
- # sql (8)
- # tools-deps (6)
- # vim (6)
- # xtdb (21)
Good 🌅 . morning
Morning!
måning
:rain_cloud::rain_cloud::rain_cloud::rain_cloud::rain_cloud::rain_cloud:
does anyone know a document that explains how Clojurescript devs should cosume JS libs these days, eg find out what the name of a JS object is that you want to require? I feel like there are docs scattered around but not a simple guide. Am I wrong?
not really - it's the same problem wherever one wants to consume JS. As it happens I was using nbb when I came up with the question so your mind-reading is powerful 🙂
So, nbb approaches JS libs as ES6 which sometimes means it's different than in projects that use CJS modules
for example OKTA - the auth service provider has several JS libraries that are actually written in typescript and how you consume them in CLJS is different eg
In general you can use an nREPL connection or js/console.log with trial and error to figure it out
Yes. So how I would do it is jump in an nbb REPL:
$ nbb
Welcome to nbb v0.5.103!
user=> (require '["@okta/okta-auth-js" :as auth])
nil
user=> auth/
auth/OktaAuth auth/crypto auth/default
When you then type auth/
followed by TAB (2x), it will come up with auto-completions
But note that this also works:
user=> (require '["@okta/okta-auth-js$default" :refer [OktaAuth]])
nil
Because some of these libraries duplicate their library object under default again to be compatible with ES6
And then you update npm, clear node modules and for the same package lock, your consuming CLJS code breaks. True story.
We were importing date-fns, and referring functions, and suddenly (with no version change of the date-fns package, mind) we had to switch to the $default syntax.
I gave up trying to understand the reasons why, it's not a productive use of my time :)
Huh, I had been wondering about this myself. This thread was enlightening… if you can call JS that.