Fork me on GitHub
#shadow-cljs
<
2020-07-10
>
jerger_at_dda08:07:24

Hi, is there a recommend way to reduce size of generated *.js? My first clojure-script project (https://github.com/DomainDrivenArchitecture/dda-masto-embed) generates 2,3M minimized js - I think that's quite large ... how should I start my quest for shrink the resulting size??

thheller08:07:58

@jerger_at_dda don't use {:optimizations :simple}. that is pretty much the reason its so large.

jerger_at_dda08:07:21

I assume closure compilers ADVANCED_OPTIMIZATIONS will map to {:optimizations :advanced} ?

thheller08:07:45

that is the default yes, just remove the setting entirely

thheller08:07:04

don't need :release {:compiler-options {:optimizations :simple}}}

thheller08:07:50

then use https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report to figure out the rest. I know that cljs-time is a pretty significant chunk too (because of its deps, not so much cljs-time itself)

thheller08:07:27

depending on what you use from it you might be better off with the code from the closure library. its about 5% the size of cljs-time.

jerger_at_dda08:07:57

optimization cut the size down to 1,5M Will investigate further with build-report ... thanx for your help 🙂

jerger_at_dda08:07:03

Is there a way to get a kind of dependency tree reported ?

Kurt Sys08:07:53

How to compile a node script where I can pass command line arguments?

:builds
 {:converter {:target :node-script
              :output-to "converter.js"
              :main  converter/run
              }
        }
I'd like to be able to do something like node converter.js group user (which would only convert groups and users)?

thheller08:07:56

@kurt.sys (defn run [group user] ...) already gets the arguments

👍 3
Kurt Sys08:07:07

oh, really, cool...

thheller08:07:59

@jerger_at_dda no tree/graph currently no

Kurt Sys08:07:06

(@thheller but they are not names args, right?)

thheller08:07:33

not sure what you mean?

jerger_at_dda08:07:34

@kurt.sys that's sth we solved in https://github.com/yogthos/mastodon-bot (see package.json, shadow-cljs.edn, core.cljs). You can install with sudo npm install mastodon-bot -g and run with mastodon-bot -h

👍 3
jerger_at_dda08:07:44

if example is good enough

thheller08:07:52

you can use something like https://github.com/clojure/tools.cli to parse the args

thheller08:07:58

or any of the many npm packages for that

thheller08:07:14

they are just passed in as strings normally

Kurt Sys08:07:21

right, check... nice.