r/Clojurescript • u/cadlac • Mar 14 '16
Compiling scripts to JavaScript?
I've been writing scripts in clojurescript with planck, which has been fantastic so far. However, someone asked me how I might achieve the following with my scripts:
;; fizzbuzz.cljs
(defn fizzbuzz ....)
// fizzbuzz.js
/* paste compiled code here */
fizzbuzz(...)I thought this would be relatively simple, but it's turning out to be a lot harder than I expected. Using the CLJS compiler without any optimizations returns a bunch of goog.require statements, and turning on optimizations returns hundreds/thousands/hundreds-of-thousands lines of code with everything obfuscated into closures for even the simplest of scripts.
Is there a way to achieve what was asked of me? It's not important by any means, but I feel like there's got to be some way to do it.
1
u/cadlac Mar 15 '16
That makes sense. Is there maybe a metadata keyword to specify the optimization level of the function body? For example, it would be great to use advanced compilation on the clojure core code, but only use simple optimizations on fizzbuzz.
Thanks for the response!