Fork me on GitHub
#shadow-cljs
<
2023-04-19
>
martinklepsch13:04:01

I've played around with Remix a bit, based on the shadow-next idea with using build hooks: https://github.com/martinklepsch/remix-cljs — I'm now running into Namespace "goog.debug.Error" already declared. — Obviously lots of moving parts with Remix but would be curious if anything has changed about how this could be approached with shadow?

thheller14:04:06

thats usually a sign that something is trying to load the cljs output twice? so my guess would be that remix is trying to reload all code before the request?

Maris16:04:44

Have you used sortable (from jquery-ui) with shadow-cljs?

Maris16:04:08

(:require
   ["jquery" :as jquery]
   ["jquery-ui"]
   ["jquery-ui/ui/widgets/sortable"]   

Maris16:04:32

main.js?version=0.1.3061:1426 TypeError: base is not a constructor
    at $.widget (widget.js:105:18)
    at eval (sortable.js:41:10)
    at eval (sortable.js:36:3)
    at shadow$provide.module$node_modules$jquery_ui$ui$widgets$sortable (sortable.js:18:1)
    at shadow.js.jsRequire (js.js:66:18)
    at shadow.js.require (js.js:113:20)

thheller16:04:41

no clue what that means. how are you using it?

Maris16:04:00

:component-did-mount
      (fn []
        (.sortable (jquery
                    (str "#" container-id))
                   #js {:revert true
                        :start  (fn [_event ui]
                                  (set! (.-startPosition (.-item ui)) (.index (.-item ui))))

                        :update (fn [event ui]
                                  (rf/dispatch [::events/reorder-media
                                                {:media-type media-type
                                                 :from (int (.-startPosition (.-item ui)))
                                                 :to (int (.index (.-item ui)))}])
                                  (.preventDefault event))})
        (.disableSelection (jquery (str "#" container-id)))
    

thheller16:04:33

yikes. why do you use jquery in a re-frame app?

😂 2
Maris16:04:34

Something similar is working fine with tooltips.

Maris16:04:54

I didn’t write this code.

Maris16:04:41

I suspect I have to require some other files from jquery-ui.

thheller16:04:22

can't say sorry. never used jquery ui

Jakub Šťastný16:04:02

Hey guys. My bundle size suddenly jumped from 2 MB to 9 MB. I run npx shadow-cljs run shadow.cljs.build-report app public/report.html to see what's going on and it reports Module: :main [JS: 1.85 MB] [GZIP: 461.65 KB]. That's what I would expect, but not the reality. • I only have 1 bundle. • I build by npx shadow-cljs compile app. • I haven't touched compiler-options. • The only recent change I did to shadow-cljs.edn was to change :deps true to :deps {:aliases [:cljs]} in order to be able to prevent ShadowCLJS from taking so much MEM via :aliases {:cljs {:jvm-opts ["-Xmx256M"]}} in deps.edn. That hardly feels related. What's going on? How can I debug this? Esp. if the report is telling me one thing and the reality is different.

Jakub Šťastný16:04:29

deps.edn

{:paths ["src"]
 :aliases {:cljs {:jvm-opts ["-Xmx512M"]}}
 :deps {org.clojure/test.check {:mvn/version "1.1.1"}
        org.clojure/spec.alpha {:mvn/version "0.3.218"}
        thheller/shadow-cljs {:mvn/version "2.22.2"}
        reagent/reagent {:mvn/version "1.2.0"}
        metosin/reitit {:mvn/version "0.6.0"}
        io.github.arttuka/reagent-material-ui {:git/sha "4fc4b44891919d2b84160eb411d52227dd89e0a5"}
        camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
                                        ; Dev dependencies.
        binaryage/devtools {:mvn/version "1.0.6"}}}

Jakub Šťastný16:04:52

shadow-cljs.edn

{:deps {:aliases [:cljs]}
 :builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn bm-web.core/main}}
 ; 
        :js-options {:anon-fn-naming-policy :unmapped}
        :output-dir "public/js"
        :target :browser}}
 :dev-http {3000 "public"}}

Jakub Šťastný17:04:17

The thing that surprises me the sudden jump from 2 to 9 MB. That's just huge. I included MUI X DatePicker and Day js, MUI is huge, but not this huge.

thheller17:04:11

compile is a development build

thheller17:04:18

you want npx shadow-cljs release app, that is also what the build report does

thheller17:04:07

but yeah this mui stuff is huge

Jakub Šťastný17:04:07

Yeah MUI really leaves me speechless at times. Both how huge it is and the complexity of that thing. Anyway, I'll stop ranting.

Jakub Šťastný17:04:26

I must have switch to compile recently by mistake and then as I do C-r to fetch it from history, that's where I kept propagating that mistake. Blimey.

hifumi12321:04:20

if you pull in @mui/icons-material then you are bundling 11,000 SVG icons (~2,000 icons with 4-5 variants each), which add up to around 5-6 MB last time I checked

Karan Ahlawat18:04:45

Hey people! I'd like to ask if it's possible to use pnpm instead of npm with shadow-cljs? Whenever I try to do that, a bunch of react deps don't get installed, and these are not user-facing dependencies either. But doing the same with npm works fine. Any ideas what might be the issue?

paulocuneo12:04:05

pnpm doesn't install peer-dependencies by default, the issue may not be clojure specify, but pnpm specific, I don't remember which flags are needed to enable peer-dependencies it was something like https://pnpm.io/npmrc#shamefully-hoist. hope this helps you.

Karan Ahlawat14:04:01

That worked, although it seems like you should set your .npmrc variable before you start installing anything. Thanks!

thheller19:04:58

never looked into pnpm, don't know

1