Hello i am looking for clojurescript(clojure like) alternatives,that generates less javascript code,even if not so optimized The reason i want this is to use it with MongoDB,clojurescript even if 2 lines of code generate like 2500 characters code and its very slow on MongoDB i found one that looks nice (the othes that i found look much smaller projects stopped years ago), but maybe there are more options https://github.com/Gozala/wisp
> clojurescript even if 2 lines of code generate like 2500 characters code Depends on what you use. Some functions and, I think, all CLJS data structures will generate a lot of code. But many won't.
E.g. this code compiles to 286 characters of JS in my setup:
(js/console.log (let [acc #js []]
(loop [i 10]
(when (pos? i)
(.push acc i)
(recur (dec i))))
acc))
hello thanks for the reply
i am new to clojurescript i compliled the code you sended like this :
clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version \"1.10.741\"}}}' -m cljs.main -O advanced -c
and result is again so big
i want one clojure function to compile to one javascript function, i done it but the code is just too big
and in mongodb is very slow
i compile my code in wrong way? is there a better way to produce smaller js file?
i compiled this
(ns jstempproject.tempnamespace)
(defn ^:export myloop []
(let [acc (js/Array)]
(loop [i 10]
(when (pos? i)
(.push acc i)
(recur (dec i)))) acc))
2583 characters
The default CLJS compiler might produce some polyfills that you don't need. I used shadow-cljs with these build parameters:
:compiler-options {:output-feature-set :es6}
:js-options {:babel-preset-config {:modules "commonjs"
:targets "chrome > 70"}}
You can specify :compiler-options
for the default CLJS compiler by using the -co
flag but it didn't work for me. I don't know if you can specify :js-options
.
i want to produce 1 js file
to run alone
Also, there might be other compiler options and js options that produce even a smaller result because I still see some small polyfill in there. Shadow-cljs does produce a single file.
ok thank you alot , i will try to compile with shadow-cljs also
is there any other alternative?
i need just small js file
is it possible to send me that temp project you made ? to see the src ?
i never used shadow-cljs
or a link of how to use shadow-cljs
This is the full source code:
(ns clj-playground.single)
(js/console.log (let [acc #js []]
(loop [i 10]
(when (pos? i)
(.push acc i)
(recur (dec i))))
acc))
And this is the whole config file:
{:source-paths ["src"]
:builds {:single {:target :browser
:output-dir "public/js/compiled-single"
:compiler-options {:output-feature-set :es6}
:js-options {:babel-preset-config {:modules "commonjs"
:targets "chrome > 70"}}
:modules {:main
{:entries [clj-playground.single]}}}}}
I ran it as shadow-cljs release single
and got a single 286 character JS file.
great thank you alot,its important for me 🙂
If you decide to stick with it, be sure to read the shadow-cljs documentation and play around with :compiler-options
and :js-options
.
yes i will read those now 🙂 have a nice day
You too!
MAL js http://kanaka.github.io/mal/
thank you clyfe i will check it now, seems that i can complile differently to produce much smaller javascript code,i am trying shadow-cljs
I have a legacy project using the old (original) figwheel. I have it working with CIDER, but I always run (stop-autobuilds) and then (start-autobuilds) to add my ‘test’ build id. Is there a way to make that happen automatically? Again, this is the old figwheel, not figwheel-main….