Fork me on GitHub
#sci
<
2023-05-03
>
oly08:05:00

I am a bit confused on how I can use libraries in sci, I am embedding sci in a clojurescript app I am setting up sci with init to create a context, I want to be able to use reagent in the context which is already required outside sci, my understanding is I need to use :namespaces is this correct and can I just expose the entire library ? Or do I need to pull in reagent into sci seperately a bit like scittle does ? hoping someone can point me in the right direction.

borkdude08:05:48

@UU67HFS2X My recommendation for reagent is to use the config from here: https://github.com/babashka/sci.configs#reagentreagent

oly08:05:06

that's great that looks like the info I was missing thanks @U04V15CAJ

borkdude08:05:21

We should link this from the SCI readme probably

oly08:05:20

yeah handy I can look at the src and see how they are included now, I see sci/copy-var is the piece ~I likely needed but I can just pull in those configs in my deps now and save myself the trouble 🙂

👍 2
oly09:05:21

great, I have managed to add in what I require and it works, I was hoping for honey but getting a sequential? does not exist so need to investigate that one but reitit seemed to work 🙂

oly09:05:08

(def rf-ns (sci/create-ns 'reitit.frontend nil))
(def rfe-ns (sci/create-ns 'reitit.frontend.easy nil))
(def rss-ns (sci/create-ns 'reitit.coercion.spec nil))
(def sql-ns (sci/create-ns 'honey.sql.core nil))
(def sqlh-ns (sci/create-ns 'honey.sql.helpers nil))
(def sci-ctx
  (sci/init
   {:namespaces
    {'reagent sci-reagent/reagent-namespace
     'sql {'format (sci/copy-var sql/format sqlh-ns)}
     'sqlh {'select (sci/copy-var sqlh/select sqlh-ns)
            'from (sci/copy-var sqlh/from sqlh-ns)
            'where (sci/copy-var sqlh/where sqlh-ns)}
     'rf {'router (sci/copy-var rf/router rf-ns)}
     'rss {'coercion (sci/copy-var rss/coercion rss-ns)}
     'rfe {'start! (sci/copy-var rfe/start! rfe-ns)
           'href (sci/copy-var rfe/href rfe-ns)}}}))
currently got these added, nice work as usual I was using klipse before but that seems to not work with the latest clojurescripts so was curious if I could use this in its place 🙂

borkdude09:05:42

sequential? does not exist ?

borkdude09:05:56

$ clj -M:cljs -m cljs.main -re node
ClojureScript 1.11.54
cljs.user=> (require '[sci.core :as sci])
nil
cljs.user=> (sci/eval-string "sequential?")
#object[cljs$core$sequential_QMARK_]

borkdude09:05:06

Need more info. honeysql should work normally

oly09:05:59

give me a sec may be more info of the edge of the screen, only just encountered it as I included the library 🙂

borkdude09:05:43

btw I recommend using the full namespace names in :namespaces. you can provide :aliases for those namespaces as well

oly10:05:03

thanks for the tips 🙂

oly10:05:24

the sequential isses was happening inside some honey code but its not related to honey, just evaling sequential? like above is giving me this from sci

oly10:05:33

#error {:message "Could not resolve symbol: seqential?", :data {:type :sci/error, :line 9, :column 1, :file nil, :phase "analysis"}}

borkdude10:05:09

seqential? seems like a typo?

oly10:05:40

ha your correct nice spot, klipse must have just ignored that else not sure why it did not show up before

borkdude10:05:04

clojurescript doesn't fail on typos, but just warns, I think

borkdude10:05:15

but SCI is more like JVM Clojure in this regard