4

I want to compile ClojureScript inside Clojure and am having some problems. I would like to do something like this:

(def x '(map (fn [n] (* n n n)) [1 2 3 4]))
(cljs->js x)

where cljs->js returns JavaScript code. I guess Himera does something similar (first reading ClojureScript from a string), but I don't know enough about ClojureScript to figure it out.

Is there are simple solution to this?

2 Answers 2

1

Have you look at the Himera code? Here is where the code sent by the UI is compiled, which basically calls the cljs.compiler from the clojurescript project. Note that Himera is probably a lot more complex than what you are asking for, probably you just need to get the "compilation" function working

Sign up to request clarification or add additional context in comments.

Comments

0

once you have the clojurescript dependencies sorted out (which is it's own question) then you can just call the clojurescript emit function. this is used in the Clutch project (couchdb for clojure+clojurescript). it basically looks like this:

(js/emit (aget doc "_id") nil)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.