This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-12
Channels
- # adventofcode (78)
- # announcements (5)
- # babashka (22)
- # beginners (230)
- # calva (18)
- # cider (26)
- # clj-kondo (1)
- # cljs-dev (1)
- # clojure (14)
- # clojure-austin (1)
- # clojure-dev (3)
- # clojure-europe (30)
- # clojure-switzerland (1)
- # clojure-uk (26)
- # clojurescript (33)
- # conjure (2)
- # cursive (2)
- # data-science (1)
- # datomic (9)
- # docker (1)
- # emacs (8)
- # events (4)
- # fulcro (64)
- # lambdaisland (3)
- # luminus (1)
- # off-topic (3)
- # pathom (6)
- # portal (1)
- # programming-beginners (5)
- # shadow-cljs (22)
- # tools-deps (8)
- # xtdb (4)
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))
clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version \"1.10.741\"}}}' -m cljs.main -O advanced -c
i want one clojure function to compile to one javascript function, i done it but the code is just too big
(ns jstempproject.tempnamespace)
(defn ^:export myloop []
(let [acc (js/Array)]
(loop [i 10]
(when (pos? i)
(.push acc i)
(recur (dec i)))) acc))
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
.
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.
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]}}}}}
If you decide to stick with it, be sure to read the shadow-cljs documentation and play around with :compiler-options
and :js-options
.
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….