This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-09
Channels
- # announcements (14)
- # architecture (42)
- # babashka (23)
- # beginners (37)
- # biff (8)
- # calva (2)
- # cider (3)
- # clara (42)
- # clerk (14)
- # clojure (55)
- # clojure-brasil (3)
- # clojure-dev (5)
- # clojure-europe (18)
- # clojure-hungary (88)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (66)
- # clojure-uk (9)
- # clojurescript (16)
- # core-logic (16)
- # datomic (6)
- # fulcro (32)
- # hyperfiddle (25)
- # instaparse (12)
- # joyride (2)
- # lsp (13)
- # malli (15)
- # off-topic (50)
- # polylith (11)
- # portal (3)
- # re-frame (2)
- # reitit (2)
- # sci (8)
- # shadow-cljs (16)
- # tools-deps (13)
- # xtdb (5)
Hey friends. Thanks for making shadow-cljs! I'm really enjoying it! I'm stuck on one thing, though. I have my project working in development mode, which targets the browser. However, when I make a release build, I get an error "Uncaught Error: Invalid arity: 4" with an incomprehensible stacktrace. Can anyone help me where to start?
I suspect the problem happens because Im using the react-syntax-highlighter library.
["react-syntax-highlighter/dist/esm/prism-light.js$default" :as SyntaxHighlighter]
But I don't know what might be wrong or how to fix itIt seems if I set optimizations to :simple, it all works ok 🙂 Curious what might be going on though
npm code should all go through simple optimizations already. do you have a small example of your code and build configuration
my only guess at the moment is that npm code somehow went through advanced optimizations, which is only possible in shadow-cljs if you explicitly set that cf. https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider
{:lein {:profile "+cljs"}
:builds
{:website
{:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:shared {:entries []}
:index {:init-fn io.shadowtraffic.website.index/init
:depends-on #{:shared}}
:pricing {:init-fn io.shadowtraffic.website.pricing/init
:depends-on #{:shared}}
:contact {:init-fn io.shadowtraffic.website.contact/init
:depends-on #{:shared}}}
:preloads [devtools.preload]
:dev {:compiler-options
{:optimizations :simple
:closure-defines
{re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}}}}}
:dev-http {8080 "public"}}
(I explicitly set simple to fix what I was running into)
Anyway, I wont make you run it down since it all seems good enough at the moment. Thank you for taking a stab at a hypothesis 🙂
you can use npx shadow-cljs release website --pseudo-names
to make the stacktrace somewhat legible
or npx shadow-cljs release website --debug
to also add source maps, which makes everything somewhat debuggable, although sometimes source maps actually make it more complicated. definitely try though.
Uncaught Error: Invalid arity: 4
is usually an IFn.invoke related error, i.e. calling a (thing 1 2 3 4)
when thing
is something implementing IFn
but omitting that arity
don't use :simple
or --debug/--pseudo-names
builds in production though, they are far too huge
what is always a possibility and can be rather hard to track down is externs related things. if --pseudo-names
fixes it, it most certainly is externs related. most often this is caused by "incorrect" JS interop or not accounting for external JS included in the page but having no externs present. one cause is for example google analytics with its ga
variable. ga
is very likely variable name to be generated by :advanced
. so effectively google analytics (or any other JS, not part of the build) replaces your code in bad ways, leading to errors such as this
Aha, thanks for letting me know. Ill try to track this down today then
This weirdly seems to have resolved itself. At some point I had to rm my .shadow-cljs directory to fix another issue. Perhaps something got gunked up there