Fork me on GitHub
#shadow-cljs
<
2022-03-24
>
Oliver George00:03:22

Funny that should be the topic right now. I'm here to ask if there's a recommendation for how to break up that vendor bundle because the page is taking 5s to load!

Oliver George00:03:35

In my case there's a dependency needed for generating PDFs which isn't needed immediately. That adds something like 2.5mb to the js. (https://react-pdf.org/)

thheller06:03:03

and then the modules however make sense for your project

thheller06:03:17

there I have codemirror which is also a pretty large dependency. I delay loading it until it is actually used.

Oliver George08:03:49

Seems like :js-provider :external might complicate this

Oliver George08:03:14

But that's speculation. I’ll give it a go.

thheller08:03:49

that is correct yes. :external will move all JS deps into one single file.

thheller08:03:17

the way webpack handles code splitting is entirely different than the closure compiler. so the two don't really get along.

thheller08:03:47

in theory it should be possible to combine the two somehow. just haven't figured out how that would need to look on the webpack side or how you'd even configure that

thheller08:03:22

if some webpack export wants to help out I'd be happy to write the cljs side of things 😛

Oliver George08:03:32

Thanks. Yep. All a bit messy.

Oliver George08:03:58

I would happily ditch webpack but the pesky WASM dependency gets in the way.

thheller08:03:35

some wasm deps allow you to control how the wasm is actually loaded

thheller08:03:53

in that case it can be easily integrated but it all depends on how that wasm glue code came about

thheller08:03:56

I did some stuff a while ago, maybe that is still accurate in some way https://github.com/thheller/wasm-pack-cljs

Oliver George08:03:33

Thanks again. I'm really not across the wasm details. This react-pdf dep is wrapping pdfkit which is probably quite professional I guess.

thheller08:03:22

pretty sure pdfkit also offers a CDN version. so that may also work

thheller08:03:47

so even just moving out pdfkit can work

Oliver George08:03:10

I’ll look into that - thanks again

wombawomba09:03:38

@thheller UX suggestion: the "dependency trace" tooltip in the build report tends to go off-screen (and thus become unreadable) when there are lots of modules. It'd be better to use an expand/collapse toggle like what you already have for the "groups".

bastion12:03:06

I’m trying to set up a web worker, but I keep getting the error worker.js:67 Uncaught Error: Namespace "goog.dispose" already declared.. Does anyone know why this is? shadow-cljs config:

:worker {:init-fn my.app.worker/load!
         :depends-on #{:shared}
         :web-worker true}}
my.app.worker:
(ns my.app.worker)

(js/console.log "worker/read!")

(defn load! []
  (js/console.log "worker/load!"))
http://my.app:
(defn init []
  (let [worker (js/Worker. "/js/worker.js")]
    (.addEventListener worker "message" notify-worker-message)))

bastion18:03:09

^ solution: needed to update shadow-cljs. Was the first thing I tried, but my globally installed version of node_modules was using 2.16.12. Updated it to the latest and everything worked like a charm 🙂

👍 1