clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
takis_ 2020-12-12T10:00:30.276300Z

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

p-himik 2020-12-12T11:47:59.276800Z

> 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.

p-himik 2020-12-12T11:51:31.277Z

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))

takis_ 2020-12-12T12:05:28.277200Z

hello thanks for the reply

takis_ 2020-12-12T12:05:52.277400Z

i am new to clojurescript i compliled the code you sended like this :

takis_ 2020-12-12T12:05:55.277600Z

clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version \"1.10.741\"}}}' -m cljs.main -O advanced -c

takis_ 2020-12-12T12:06:02.277800Z

and result is again so big

takis_ 2020-12-12T12:06:32.278Z

i want one clojure function to compile to one javascript function, i done it but the code is just too big

takis_ 2020-12-12T12:06:39.278200Z

and in mongodb is very slow

takis_ 2020-12-12T12:07:05.278400Z

i compile my code in wrong way? is there a better way to produce smaller js file?

takis_ 2020-12-12T12:11:11.278700Z

i compiled this

takis_ 2020-12-12T12:11:27.278900Z

(ns jstempproject.tempnamespace)

(defn ^:export myloop []
  (let [acc (js/Array)]
    (loop [i 10]
      (when (pos? i)
        (.push acc i)
        (recur (dec i)))) acc))

takis_ 2020-12-12T12:11:43.279100Z

2583 characters

p-himik 2020-12-12T12:15:05.279300Z

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"}}

p-himik 2020-12-12T12:15:33.279500Z

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.

takis_ 2020-12-12T12:15:55.279700Z

i want to produce 1 js file

takis_ 2020-12-12T12:16:01.279900Z

to run alone

p-himik 2020-12-12T12:16:20.280100Z

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.

takis_ 2020-12-12T12:16:52.280300Z

ok thank you alot , i will try to compile with shadow-cljs also

takis_ 2020-12-12T12:17:13.280500Z

is there any other alternative?

takis_ 2020-12-12T12:17:42.280700Z

i need just small js file

takis_ 2020-12-12T12:18:19.280900Z

is it possible to send me that temp project you made ? to see the src ?

takis_ 2020-12-12T12:18:32.281100Z

i never used shadow-cljs

takis_ 2020-12-12T12:19:54.281300Z

or a link of how to use shadow-cljs

p-himik 2020-12-12T12:22:52.281500Z

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]}}}}}

p-himik 2020-12-12T12:23:18.281700Z

I ran it as shadow-cljs release single and got a single 286 character JS file.

takis_ 2020-12-12T12:23:43.281900Z

great thank you alot,its important for me 🙂

p-himik 2020-12-12T12:25:35.282100Z

If you decide to stick with it, be sure to read the shadow-cljs documentation and play around with :compiler-options and :js-options.

takis_ 2020-12-12T12:26:01.282300Z

yes i will read those now 🙂 have a nice day

p-himik 2020-12-12T12:26:14.282500Z

You too!

clyfe 2020-12-12T14:39:48.282800Z

MAL js http://kanaka.github.io/mal/

takis_ 2020-12-12T14:52:03.284200Z

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

jmckitrick 2020-12-12T21:08:09.286400Z

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….