Fork me on GitHub
#clojurescript
<
2022-06-03
>
Edward Ciafardini01:06:13

Anyone have a preferred method of rendering colored code blocks with line numbers in hiccup?

rolt09:06:22

i've never used it, but highlight.js with highlightjs-line-numbers ?

rolt09:06:34

or codemirror actually

Sam Ritchie13:06:03

Hey all - I am attempting to test #sicmutils’s build with this https://github.com/henryw374/clojurescript-library-consumers-test project, and I’m hitting an error that I do NOT see with shadow-cljs compilation:

SEVERE: /Users/sritchie/code/clj/clojurescript-library-consumers-test/cljsjs/out/sicmutils/numbers.js:389:7: ERROR - [JSC_LANGUAGE_FEATURE] This language feature is only supported for ECMASCRIPT_2016 mode or better: exponent operator (**).
  389| return a ** b;
has anyone seen this before?

Sam Ritchie13:06:39

The issue is definitely coming from

(defmethod g/expt [js/BigInt js/BigInt] [a b]
       (if (g/negative? b)
         (g/invert (js* "~{} ** ~{}" a (core/- b)))
         (js* "~{} ** ~{}" a b)))

mauricio.szabo01:06:01

Check the target version for closure compiler. By default, it compiles to a very old ecmascript version.

👍 1
dnolen13:06:38

@sritchie09 I think you need to set :lang-in - shadow probably just picks a later one by default

Sam Ritchie13:06:26

@dnolen okay nice, stumbled on that now and that works. I’m assuming there’s no way to specify in a library that consumers need to set :language-in :es-2016, yeah? I’ll add a note to the docs

dnolen13:06:49

@sritchie09 open a JIRA ticket if you can to set this as default, patch also welcome

Sam Ritchie16:06:59

filed a ticket for a contributor account, patch is simple

thheller16:06:11

IMHO its fine to set language-in as the highest possible option. shadow-cljs has had this at :es-next-in (or :es-unstable now) since the beginning. never had an issue with that. doesn't seem to affect any of the polyfill generation. they are controlled by language-out

Sam Ritchie17:06:33

Wdyt @dnolen ? I can submit patches now so happy to make the ticket

Sam Ritchie14:06:09

@dnolen will do in a couple hours! newborn twins at home fragmenting time 🙂 but I’m not going to miss my first chance at a patch, however small

1
kraf15:06:30

I started experimenting with reagent and shadow-cljs and the bundle size of my extremely naive project surprises me. I basically only render a [:h1 "Hello"] and do nothing else. I found the option to create a build report, I'll attach it in a thread. There I could see that react-dom is >100kb which makes me think I'm doing something wrong.

kraf15:06:40

shadow-cljs - starting via "clojure"
| Resource                             |   Optimized |  Total % |          JS |      Source |
|--------------------------------------+-------------+----------+-------------+-------------|
| npm | react-dom                      |    120.2 KB |  43.60 % |    120.5 KB |    122.2 KB |
| jar | cljs/core.cljs                 |    116.9 KB |  42.39 % |      1.3 MB |    348.0 KB |
| npm | react                          |      6.2 KB |   2.24 % |      6.2 KB |      6.8 KB |
| jar | reagent/impl/component.cljs    |      6.1 KB |   2.21 % |     26.6 KB |     17.0 KB |
| jar | reagent/ratom.cljs             |      5.8 KB |   2.09 % |     59.3 KB |     17.3 KB |
| npm | scheduler                      |      4.6 KB |   1.67 % |      4.6 KB |      5.2 KB |
| jar | reagent/impl/template.cljs     |      4.4 KB |   1.60 % |     25.8 KB |     11.2 KB |
| jar | reagent/impl/util.cljs         |      2.2 KB |   0.81 % |     31.1 KB |      6.8 KB |
| jar | reagent/impl/batching.cljs     |      1.8 KB |   0.64 % |      7.5 KB |      3.1 KB |
| jar | reagent/impl/input.cljs        |      1.7 KB |   0.60 % |      6.0 KB |      5.8 KB |
| jar | clojure/string.cljs            |      1.0 KB |   0.38 % |     14.7 KB |      8.4 KB |
| npm | object-assign                  |    993.0 B  |   0.36 % |    994.0 B  |      2.2 KB |
| jar | reagent/impl/protocols.cljs    |    948.0 B  |   0.34 % |      4.9 KB |    194.0 B  |
| jar | clojure/set.cljs               |    532.0 B  |   0.19 % |     14.3 KB |      5.0 KB |
| jar | goog/object/object.js          |    508.0 B  |   0.18 % |     21.4 KB |     21.4 KB |
| jar | shadow/js.js                   |    495.0 B  |   0.18 % |      3.2 KB |      3.2 KB |
| jar | reagent/dom.cljs               |    471.0 B  |   0.17 % |      7.0 KB |      2.7 KB |
| jar | goog/string/stringbuffer.js    |    308.0 B  |   0.11 % |      2.3 KB |      2.3 KB |
| jar | goog/base.js                   |    241.0 B  |   0.09 % |    128.7 KB |    128.7 KB |
|     | gomore/app.cljs                |    168.0 B  |   0.06 % |    661.0 B  |    559.0 B  |
|     | shadow/module/main/append.js   |     89.0 B  |   0.03 % |    118.0 B  |    118.0 B  |
| jar | goog/string/string.js          |     81.0 B  |   0.03 % |     47.8 KB |     47.8 KB |
| jar | goog/string/internal.js        |     40.0 B  |   0.01 % |     12.3 KB |     12.3 KB |
| jar | reagent/debug.cljs             |      9.0 B  |   0.00 % |      2.9 KB |    614.0 B  |

kraf15:06:03

Does anybody have an idea about what I could do to make this a bit smaller?

kraf15:06:36

For reference, this is my shadow-cljs.edn

{:deps
 {:aliases [:cljs]}

 :dev-http
 {8020 "packs"}

 :builds
 {:app
  {:target :browser
   :output-dir "packs/cljs"
   :asset-path "/packs/cljs"
   :modules
   {:main
    {:init-fn 
     :compiler-options {:optimizations :advanced}}}}}}

p-himik15:06:16

GZipping it, as the page suggests, would reduce the size significantly. And if you really care about the bundle size, you might be interested in React replacements that preserve [some of] the API and are generally compatible with Reagent. But I wouldn't suggest that for a beginner.

p-himik15:06:15

Alternatively, you can replace Reagent with something else entirely, something that's not React-based. Finally, just as some food for thought - it all depends on your particular application, but 120-130 kB is almost nothing. Usually even a random picture takes much more space.

kraf15:06:04

Oh that's a nice page, thanks for looking this up! Yeah you're right, it's not that bad. Just out of curiosity, what are those replacements?

p-himik16:06:45

I remember hearing about Preact. But I'd have to do a web search just as well since I don't really follow those trends.

dgb2316:06:48

I haven't tried with Reagent but Preact is generally one that is very close.