This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-06
Channels
- # aleph (1)
- # beginners (180)
- # calva (16)
- # cider (29)
- # clj-kondo (47)
- # cljsrn (5)
- # clojure (40)
- # clojure-dev (39)
- # clojure-europe (1)
- # clojure-italy (25)
- # clojure-nl (9)
- # clojure-russia (1)
- # clojure-spec (8)
- # clojure-uk (83)
- # clojurescript (54)
- # core-async (2)
- # datomic (20)
- # defnpodcast (7)
- # figwheel (6)
- # fulcro (6)
- # jobs (5)
- # joker (4)
- # kaocha (4)
- # luminus (4)
- # off-topic (8)
- # onyx (6)
- # pathom (14)
- # re-frame (28)
- # reagent (30)
- # remote-jobs (2)
- # shadow-cljs (88)
- # spacemacs (2)
- # specter (17)
- # sql (25)
- # tools-deps (78)
- # xtdb (1)
- # yada (2)
Hello, while migrating our application to shadow-cljs I am running into issues trying to get the code to run with a release. The code runs fine in dev mode. However, when I run it as a release I get an Invarient Violation from React. It seems like React is eating up the error so I can't figure out what is going wrong. Is there a way I could do the advanced compilation but some how set the NODE_ENV
to development so React will give me the error?
I’m a shadow-cljs beginner really, so I don’t have the answer, but do you know about shadow-cljs check
? Maybe it helps, I would have liked to know about it earlier a few months ago 🙂
I have run shadow-cljs check and it gives me some warnings. Most warnings are in external library code, but none that seem like they would break only in a release
do you have :infer-externs :auto
turned on? it is most likely related to missing externs and using property access for something https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs
Whew! That was a crazy issue. Ultimately it had little to do with shadow-cljs. We had an in-house JavaScript library called paradigm and when we did the original interop with lein we just had it provide the same namespace that the global object provided paradigm
. However when I followed the technique described to convert CLJSJS packages things went wrong in a weird way when released. Somehow the code was optimizing in a way that js/paradigm
was resolving to the cljs paradigm
namespace rather than the paradigm
that we exported globally. I have no clue why this was happening only on a release build but worked fine in dev. Changing the namespace to avoid clashing with the global object fixed it.
I cannot seem to make "release" build of my firebase app work. My development build runs fine. If I serve the js files compiled using shadow cljs normal build using firebase serve
, the app works, but if i do shadow-cljs release main
(main is the app build), and do firebase serve
I get errors for firebase. It does not initialize firebase and app does not show up. Is there a way to test advanced build using shadow-cljs?
I tried
:dev {:compiler-options
{
:optimizations :advanced
:closure-defines {re_frame.trace.trace_enabled? true
day8.re-frame.tracing.trace-enabled? true
;goog.DEBUG false
}}}
but for the main build but i cannot seem to force shadow-cljs to do :advanced
optimizations on the build
@thheller is there a way to force :optimizations :advanced
on the normal (non-release) builds? using that key value on compiler-options did not seem to create advance optimized builds
What I am facing is : Uncaught TypeError: firebase.initializeApp is not a function
on the "release" version
it should be https://github.com/firebase/firebase-js-sdk/blob/master/packages/firebase/app/index.ts#L19
but since I am using https://github.com/deg/re-frame-firebase, i think it is getting initialized twice (wrongly in release build)
when i debug, I can see it is just an object instead of the actual firebase object in the js code, but since this only happens in advanced optimization, i am not sure why it is happening
may be it is in conflict with the firebase I have in the package.json file. Let me try to remove the one in package.json and try again
you are basically relying on this "shim" to create the global js/firebase
that library uses
thank you for the pointers. I will check more. I am surprised that it works with shadow normal build
you can try making a release build and then when loading it in the browser you can check via the console if there is a firebase
variable
maybe try compiling with shadow-cljs release main --pseudo-names
and debug it in the browser
@neupsh I've been trying to elucidate that exact behavior myself for the last three weeks. I also use re-frame-firebase
Similarly, I’ve traced it down to a double declaration of “var firebase” that in the re-frame-firebase initialization scope overloads the goog.exportSymbol’s firebase. I’ll try the above recommendations too and report back if that helps debug. Thank you.
In the "advanced optimized" js if i search for "firebase" I see two places where that var is assigned a value. One for global and one for local (in scope of that reframe lib node module init function).
The global one has correct value right after it is assigned, but the local scoped one is initialized as an empty object and then for each modules (sub modules?) they are added as properties of the "firebase" local object. Now, this object may have those submodules, but it does not have the "initializeApp()" method as it is never added to that object.
yes, in the debugger, at the point firebase.initializeApp is called, firebase is a nearly empty object, with properties (this is from my recent memory, so may be missing things)
{auth: {}, database: {}, firestore: {}} which is also initialized in that containing scope by a similar assignment to the var firebase = {app: {}} (I’m using :simple optimizations, so the app: {} nor other empties are being optimized out, forgot to mention that)
immediately prior to use of say firestore, there’s a dummy dec’l firebase.firestore = {}
BTW, did you get --pseudo-names to do anything useful, I’m on the horns of that now, with a … TypeError : $s$$.substring is not a function
Separately, I have a minimal app that exhibits this “firebase.initializeApp not a function” behavior that I can share
@U20AW42V7 I have not got around to try that yet 🙂 I only get to play with clojure(script) off work.
Tried to spend some time without any progress.. I will continue tomorrow. Lets get to the bottom of this 🙂
@thheller I’m in the middle of cleaning it up right now, thank you. Last minute npm wrestling.
https://github.com/benzenwen/re-frame-firebase-shadow-cljs-interaction-test/tree/master
Apologies for letting /semantic sneak in there! Thank you for shadow-cljs. Am going to turn in for the evening.
one last thing, I have a fork of shadow-cljsjs and/or re-frame-firebase that seems to supress the :dev build warning:
‘‘’ Warning: Firebase is already defined in the global scope. Please make sure Firebase library is only loaded once. shadow$provide.module$node_modules$$firebase$app$dist$index_cjs @ index.cjs.js:484 shadow.js.jsRequire @ js.js:63 shadow.js.require @ js.js:97 (anonymous) @ firebase.app.js:3 ‘’'