clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
sansarip 2021-06-07T01:54:51.112200Z

Hello, fine people! I get errors when trying to eval a custom macro in cljs, but the macro works just fine otherwise in cljs. And when I say "custom macro", I simply mean one that I've defined.

(ns peanuts.editor
  (:require [cljs.js :refer [empty-state eval-str js-eval]]))

(defn evaluate 
 [s cb]
 (eval-str
   (empty-state)
   (str "(do " s ")")
   nil
   {:eval       js-eval
    :source-map true
    :context    :expr}
   cb))

=> (evaluate "(require-macros '[peanuts.core :refer [defnc]]) (defnc foo [a] a) (foo 1)" println)

{:error #error {:message ERROR, :data {:tag :cljs/analysis-error}, :cause #object[TypeError TypeError: cljs.user.defnc is undefined]}}
nil
I even tried setting the :ns option on eval-str to 'peanuts.core and then trying to evaluate defnc without the require, but that yielded another error:
=> (evaluate "(defnc foo [a] a) (foo 1)" println)
{:error #error {:message ERROR, :data {:tag :cljs/analysis-error}, :cause #object[SyntaxError SyntaxError: expected expression, got '.']}}
nil
Is there a way to eval custom macros in cljs :simple_smile: ?

Oliver George 2021-06-07T02:03:31.114700Z

Hi Guys, quick cross-promotion. I've started a #show-and-tell channel. Share a screenshot and tell us about it. So far we've seen some interesting developer setups and side projects. Today I've shared a facilitaties management solution we developed using, among other things, #re-frame & #cljsrn.

3πŸ‘
Oliver George 2021-06-07T02:07:36.115300Z

And if broad-scope facilities management solutions don't inspire you... well, I can't imagine what will.

Jacob Rosenzweig 2021-06-07T04:07:46.116200Z

Any idea why I get this error when I attempt to start a shadow-cljs project I generated?

PS C:\Users\Jacob\clojure\my-app> shadow-cljs watch app
shadow-cljs - config: C:\Users\Jacob\clojure\my-app\shadow-cljs.edn
shadow-cljs - starting via "clojure"
clojure : The term 'clojure' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ clojure -m shadow.cljs.devtools.cli --npm watch app
+ ~~~~~~~

thheller 2021-06-07T07:06:22.118500Z

(or just use :dependencies and :source-paths in shadow-cljs.edn and remove :deps)

Jacob Rosenzweig 2021-06-07T04:08:20.116900Z

I'm using this npm package for context. https://github.com/jgoodhcg/create-expo-cljs-app I think what is happening is that the new :deps option leads to code trying to launch a clojure repl using the keyword "Clojure"

Jacob Rosenzweig 2021-06-07T04:52:43.117500Z

Also, could anyone tell me what the :> operator is in hiccup? E.g.

[:> rn/View ]

thheller 2021-06-07T06:40:53.118100Z

looks like the template uses deps.edn to manage dependencies but you do not have tools.deps installed?

thheller 2021-06-07T07:06:22.118500Z

(or just use :dependencies and :source-paths in shadow-cljs.edn and remove :deps)

rossputin 2021-06-07T16:27:27.121300Z

hi - can anyone point me to an example integrating Aero into a clojurescript project? Thanks!

sova-soars-the-sora 2021-06-07T16:30:29.121400Z

What's aero and what does it do? looks like a lot of different things to give a live coding experience but i'm not sure what it does

p-himik 2021-06-07T16:36:29.121600Z

It's probably https://github.com/juxt/aero, just a config library. @rossajmcd What exactly do you expect to get from it in a CLJS app? What do you mean by "integrate" here?

rossputin 2021-06-07T16:38:15.121900Z

I was wondering if there is any way my clojurescript app (in a mono repository) can share some config I use in the clojure backend

rossputin 2021-06-07T16:38:40.122100Z

not precious about it being Aero - just thought it looked like a pretty good way to do things on the Clojure side

p-himik 2021-06-07T16:41:07.122400Z

You can read that config in a CLJ macro and embed as data in a CLJS script.

rossputin 2021-06-07T16:48:17.122600Z

thanks for the pointer

sansarip 2021-06-07T22:34:12.131200Z

Anyone know if it’s possible to eval-str referred macros in Cljs? I’m having trouble doing so. e.g.

(eval-str
     (empty-state)
     "(require-macros '[some-library :refer [some-macro]]) (some-macro)"
     nil
     {:eval       js-eval
      :source-map true
      :context    :expr}
     println) 

thheller 2021-06-07T22:44:37.131700Z

depends on the library and the macro. not all macros are automatically self-host compatible.

1πŸ‘