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: ?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.
And if broad-scope facilities management solutions don't inspire you... well, I can't imagine what will.
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
+ ~~~~~~~
https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows
(or just use :dependencies
and :source-paths
in shadow-cljs.edn
and remove :deps
)
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"
Also, could anyone tell me what the :>
operator is in hiccup? E.g.
[:> rn/View ]
https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md
looks like the template uses deps.edn
to manage dependencies but you do not have tools.deps installed?
hi - can anyone point me to an example integrating Aero into a clojurescript project? Thanks!
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
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?
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
not precious about it being Aero - just thought it looked like a pretty good way to do things on the Clojure side
You can read that config in a CLJ macro and embed as data in a CLJS script.
thanks for the pointer
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)
depends on the library and the macro. not all macros are automatically self-host compatible.