Fork me on GitHub
#clojurescript
<
2023-03-09
>
coetry01:03:23

anybody know why i can’t alias the reitit.frontend namespace in my cljs repl?

cljs.user> (require '[reitit.frontend :as rf])
nil
cljs.user> rf/router
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:1
 No such namespace: rf, could not locate rf.cljs, rf.cljc, or JavaScript source providing "rf"
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:1
 Use of undeclared Var rf/router
--------------------------------------------------------------------------------

nil
cljs.user> 

coetry01:03:58

i can access the full namespace just fine:

cljs.user> reitit.frontend/router
#object[reitit$frontend$router]

thheller06:03:23

should be fine? which REPL is this? shadow-cljs?

thheller06:03:54

hmm no I guess not shadow-cljs, don't recognize the error message. should still work though :P

coetry12:03:18

it is indeed shadow!

thheller14:03:27

cljs.user=> rf/router
#object[reitit$frontend$router]

thheller14:03:32

works fine for me? which version?

coetry16:03:33

hmm in my emacs minibuffer i’m seeing [pending-cljs], although the shadow server is running and I can connect (this is with CIDER) shadow version: 2.20.16 . I think this might be a CIDER issue, but not sure how to dig further into this

coetry16:03:32

the shadow server is started in a separate terminal and then I connect to the nrepl server with cider-connect-cljs

coetry16:03:48

the relevant debugging messages from nrepl:

(-->
  id         "8"
  op         "eval"
  session    "11c05907-8541-4d5a-819a-f7103a592597"
  time-stamp "2023-03-09 10:44:47.940885000"
  code       "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow..."
  ns         "shadow.user"
)
(<--
  id         "8"
  session    "11c05907-8541-4d5a-819a-f7103a592597"
  time-stamp "2023-03-09 10:44:48.039296000"
  out        "To quit, type: :cljs/quit
"
)
(<--
  id         "8"
  session    "11c05907-8541-4d5a-819a-f7103a592597"
  time-stamp "2023-03-09 10:44:48.040727000"
  ns         "cljs.user"
  value      "[:selected :app]"
)
(<--
  id         "8"
  session    "11c05907-8541-4d5a-819a-f7103a592597"
  time-stamp "2023-03-09 10:44:48.040932000"
  status     ("done")
)

coetry16:03:23

i’m able to eval forms like (js/alert "…") without issue, but evaluating forms from within a cljs buffer and other things like aliasing namespaces don’t work

coetry16:03:05

I experience this only when I connect to an nrepl server started in a separate terminal, but not when i jack in and start up a new one directly from emacs

thheller20:03:44

that all looks fine. can you try just running npx shadow-cljs cljs-repl your-build-id and just trying the snippet from above?

thheller20:03:00

just seeing if it is nrepl or something else

thheller20:03:48

I don't have a clue about emacs related things so can't help diagnose any of that

macrobartfast02:03:41

Has anyone built anything with cljs for a WordPress site? Just saw ReactPress… https://wordpress.org/plugins/reactpress/.

macrobartfast02:03:13

Helping a friend with their wordpress site (sigh) but then they asked for the wordpress-impossible… and I thought… “yay! maybe I can get some cljs into the mix!.

coetry03:03:21

maybe grab some data from the wp-api and spin up a cljs frontend that does something interesting with that data?

macrobartfast03:03:52

I don’t know anything about WP… I’ll look at the API.

macrobartfast03:03:12

They want a graphic that changes when one plays different sound samples arrayed around the image.

macrobartfast03:03:03

but, actually, a data viz would be cool to throw in there somewhere, too.

coetry03:03:24

most newer versions should have the api under /wp-json

coetry03:03:02

and you can consult the api ref to get a better idea of how to use it: https://developer.wordpress.org/rest-api/key-concepts/

macrobartfast04:03:12

So, nice… it sounds like you can stick anything into a WP site…

macrobartfast04:03:25

I’m not sure I even need API calls in this case (the not-data-viz example).

athomasoriginal16:03:19

Which tools do people use for ClojureScript to check for security vulnerabilities and CVEs?

lread16:03:12

I don't know for ClojureScript libs, but for npm deps, I use npm audit. And GitHub also lets me know when an npm package has a security issue. Curious to know what others use.

rads20:03:19

Not specific to ClojureScript, but this could be useful in addition to npm audit: https://github.com/rm-hull/nvd-clojure

lread13:03:25

@U0CLCL6T0, I use nvd-clojure on some Clojure projects. I'm not sure if it helps too much with ClojureScript vulnerabilities. @U45T93RA6, who generously maintains nvd-clojure, might be able to tell us more.

🙌 2
vemv15:03:17

It's not expected to help with js/cljs dependencies. In fact nvd-clojure, by default, disables all analysis from other langs (.net, ruby, js, ...) for reducing false positives. Since nvd-clojure/DependencyCheck are classpath and .jar based, they won't analyze relevant .js files since nowadays most deps are expressed as npm dependencies which are rarely if ever in the classpath.

rads15:03:29

Makes sense, thanks for the clarification

leif18:03:15

Is there any way I can reprovide a macro in clojurescript?

leif18:03:12

Like, if file internal.cljs has a macro, but I want it to be brought in whenever frontend.cljs is required, is there anyway I can do that.

leif18:03:03

Actually, this might qualify as a beginner clojure question, I'll ask there.

kennytilton19:03:37

I used to worry about that, then saw a clarification that "beginner" refers to the poster, not the question. That said, see you in #C053AK3F9!

skylize22:03:00

I consider myself just slightly above beginner, but still tend to ask in #C053AK3F9. If it feels like my question is obscure, digging in the weeds of Clojure internals, or otherwise just simply "above the head" of what a beginner should be expected to either know or be learning about, then I bring it here to #C03S1KBA2. Personally, I think this falls under the "obscure" category, and I would have left it here. But that's just me. 🤷