Hi! I recently added https://github.com/muxinc/media-elements/tree/main/packages/shaka-video-element as a dependency to my project and I stumbled upon some build failures regarding private fields not being available to the Closure compiler. This prompted me to offload the build of the JS dependencies to esbuild via :js-provider :external but I'm now facing issues on shadow release:
Uncaught TypeError: Cannot read properties of undefined (reading 'Bb')
at main.64F3C2F0ED623E1CC103C4EEC12B0302.js:1935:357
at c.C9 [as qd] (main.64F3C2F0ED623E1CC103C4EEC12B0302.js:1936:115)
at main.64F3C2F0ED623E1CC103C4EEC12B0302.js:802:121
at MS (main.64F3C2F0ED623E1CC103C4EEC12B0302.js:802:347)
at main.64F3C2F0ED623E1CC103C4EEC12B0302.js:808:402
at pS (main.64F3C2F0ED623E1CC103C4EEC12B0302.js:780:277)
at HS (main.64F3C2F0ED623E1CC103C4EEC12B0302.js:801:34)
at c.render (main.64F3C2F0ED623E1CC103C4EEC12B0302.js:808:364)
The above error occurred in the component:
at reagent2 ()
This obviously isn't really helpful, but in one iteration I remember seeing something along the lines of "shadow#motion/react shim modules not defined" or so, but I can't reproduce it again.
Weirdly, everything seems to be working fine in dev mode
This is the repo + branch in question https://github.com/migalmoreno/tubo/tree/developmentupgrading to the latest shadow-cljs should make private fields work
the issue is likely related to externs, for which you should be getting warnings in case you are ignoring those 😛
You're right, yesterday before pushing the changes I bumped the shadow-cljs in deps.edn and it removed the build errors when not using :js-provider :externals . However, another reason that I wanted to go the esbuild route is that introducing shaka-video-element breaks my Motion animations on release (but not on dev mode). Leaving out the ["shaka-video-element/react$default" :as ShakaVideo] causes animation to work correctly again on release, and after trying out different shaka-video-element versions I found out that the problem really comes from the shaka-player dependency, but trying out different versions of that still yielded broken animations. Which is why I ultimately thought that it had to be a Closure compilation issue for the JS libs, and thought I might give the externals option a chance, but I can't get that to work either 😞
And thanks for the externs hint, I've just tried adding annotations for them but I still get the Uncaught TypeError error
Tbh I'm not sure that the esbuild error is related to the broken animations since I can't get the release with :externals to work with or without shaka-video-element, so that might be unrelated. I'm really new to esbuild so I'm also wondering if the bundle that it's producing can be understood/mapped correctly by the shadow-cljs output js
It seems that setting :optimizations :simple in :compiler-options for release fixes the animations and doesn't require me to use esbuild 🙂
@thheller what could be causing the compiler to mess with with a library's code only when another dependency is included? Is :optimizations :simple safe to use in prod?
safe sure, just very large in comparison
generally if setting :simple fixes it the cause is guaranteed to be externs
generally when you want to debug this try making the release build with npx shadow-cljs release frontend --pseudo-names. that makes the renaming somewhat recognizable, which lets you decipher what Cannot read properties of undefined (reading 'Bb') may have been and what the cause may be
--debug is also available, which is pseudo-names+source maps, but I find it generally easier to find externs issues via --pseudo-names
Thanks for the heads up. It ended up not being an externs issue, it seems like I was using the wrong dot notation to declare the Motion React elements (`motion.div` instead of (.-div motion)) so changing that finally fixed the animations on :advanced. No idea why it was working on release before adding shaka-video-element but well