This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-25
Channels
- # aleph (1)
- # announcements (6)
- # babashka (13)
- # beginners (21)
- # clj-http (25)
- # clj-kondo (23)
- # clojure (17)
- # clojure-europe (49)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (4)
- # clojuredesign-podcast (15)
- # clojurescript (6)
- # cursive (18)
- # datomic (22)
- # emacs (29)
- # hyperfiddle (55)
- # introduce-yourself (4)
- # polylith (34)
- # portal (10)
- # releases (1)
- # shadow-cljs (16)
- # spacemacs (2)
Hello! I am trying to emit a javascript string from clojure using the cljs.compiler.api but i am having issues with the analyzer. Has someone tried to do something similar?
Is this what you want?
(binding [cljs.env/*compiler* (cljs.env/default-compiler-env)]
(cljs.closure/compile '(defn f [x] (inc x)) {}))
=> "cljs.user.f = (function cljs$user$f(x){\nreturn (x + (1));\n});\n"
❤️ 1
And with using only the API namespaces:
(let [env (cljs.analyzer.api/empty-env)
form '(defn f [x] (inc x))
ast (cljs.analyzer.api/analyze env form)]
(cljs.compiler.api/emit ast))
=> "cljs.user.f = (function cljs$user$f(x){\nreturn (x + (1));\n});\n"
❤️ 1