Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore dependency causes Uncaught ReferenceError: $module$firebase_compat_app is not defined #346

Closed
shubhamsinghshubham777 opened this issue Jan 3, 2023 · 4 comments

Comments

@shubhamsinghshubham777
Copy link

Hi! I'm trying to implement a KMP application that supports Android, iOS, and JS. I've only just started developing the app and it works fine while I have the following dependencies:

implementation("dev.gitlive:firebase-common:1.6.2")
implementation("dev.gitlive:firebase-auth:1.6.2")

Now, as soon as I introduce the firestore dependency and make use of firestore in my repository code,

implementation("dev.gitlive:firebase-common:1.6.2")
implementation("dev.gitlive:firebase-auth:1.6.2")
implementation("dev.gitlive:firebase-firestore:1.6.2") // Introduced this dependency

my JS app stops working giving the following error output (Note: The Android app still works fine with the same code):

Uncaught ReferenceError: $module$firebase_compat_app is not defined
    <anonymous> PlayTogetherKMP-shared.js:58
    <anonymous> PlayTogetherKMP-shared.js:3
    <anonymous> PlayTogetherKMP-shared.js:30
    js main.bundle.js:3345
    __webpack_require__ main.bundle.js:3900
    fn main.bundle.js:4111
    <anonymous> PlayTogetherKMP-web.js:3
    <anonymous> PlayTogetherKMP-web.js:87
    js main.bundle.js:3355
    __webpack_require__ main.bundle.js:3900
    <anonymous> main.bundle.js:4989
    <anonymous> main.bundle.js:4992
    webpackUniversalModuleDefinition main.bundle.js:17
    <anonymous> main.bundle.js:18
[PlayTogetherKMP-shared.js:58](webpack://web/kotlin-dce-dev/PlayTogetherKMP-shared.js?0699)
    <anonymous> PlayTogetherKMP-shared.js:58
    <anonymous> PlayTogetherKMP-shared.js:3
    <anonymous> PlayTogetherKMP-shared.js:30
    js main.bundle.js:3345
    __webpack_require__ main.bundle.js:3900
    fn main.bundle.js:4111
    <anonymous> PlayTogetherKMP-web.js:3
    <anonymous> PlayTogetherKMP-web.js:87
    js main.bundle.js:3355
    __webpack_require__ main.bundle.js:3900
    <anonymous> main.bundle.js:4989
    <anonymous> main.bundle.js:4992
    webpackUniversalModuleDefinition main.bundle.js:17
    <anonymous> main.bundle.js:18

As soon as I remove the firestore dependency, everything starts working ✅ Now I'm not sure how to fix this issue while being able to use firestore.

Doing some research on this same error message, I could find this SOF answer where they essentially mention that Firebase has now moved to a modular SDK. With this in mind, I think someone has already tried to resolve this issue in #319

Is this a known issue that I'm facing? Or do we have a solution for this in mind? Any help is appreciated.

@Reedyuk
Copy link
Collaborator

Reedyuk commented Mar 14, 2023

i have done a new release, could you please try version 1.7.0(should be live in about 4 hours from now) and see if you get the same issue.

@shubhamsinghshubham777
Copy link
Author

With version 1.7.2, I get this error when trying to run the app:

e: Module "dev.gitlive:firebase-auth" has a reference to symbol dev.gitlive.firebase.auth/FirebaseUser.displayName.<get-displayName>|-7122534302014937473[1]. Neither the module itself nor its dependencies contain such declaration.

This could happen if the required dependency is missing in the project. Or if there is a dependency of "dev.gitlive:firebase-auth" that has a different version in the project than the version that "dev.gitlive:firebase-auth" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.

The list of "dev.gitlive:firebase-auth" dependencies that may lead to conflicts:
1. "kotlin" (a library with unknown version)
2. "dev.gitlive:firebase-app" (a library with unknown version)
3. "dev.gitlive:firebase-common" (a library with unknown version)
4. "org.jetbrains.kotlin:kotlinx-atomicfu-runtime" (a dependency of the library with unknown version or versions mismatch: "org.jetbrains.kotlin:kotlinx-atomicfu-runtime")
5. "org.jetbrains.kotlinx:atomicfu" (a library with unknown version)
6. "org.jetbrains.kotlinx:kotlinx-coroutines-core" (a library with unknown version)
7. "org.jetbrains.kotlinx:kotlinx-serialization-core" (a library with unknown version)

Project dependencies:
+--- kotlin
+--- com.playtogether:web
|    +--- kotlin
|    +--- dev.gitlive:firebase-app
|    |    +--- kotlin
|    |    +--- dev.gitlive:firebase-common
|    |    |    +--- kotlin
|    |    |    +--- org.jetbrains.kotlinx:atomicfu
|    |    |    |    \--- kotlin
|    |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core
|    |    |    |    +--- kotlin
|    |    |    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime
|    |    |    |    |    \--- kotlin
|    |    |    |    \--- org.jetbrains.kotlinx:atomicfu (*)
|    |    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-core
|    |    |         \--- kotlin
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    +--- dev.gitlive:firebase-auth
|    |    ^^^ This module requires symbol dev.gitlive.firebase.auth/FirebaseUser.displayName.<get-displayName>|-7122534302014937473[1].
|    |    +--- kotlin
|    |    +--- dev.gitlive:firebase-app (*)
|    |    +--- dev.gitlive:firebase-common (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    +--- dev.gitlive:firebase-common (*)
|    +--- dev.gitlive:firebase-firestore
|    |    +--- kotlin
|    |    +--- dev.gitlive:firebase-app (*)
|    |    +--- dev.gitlive:firebase-common (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    +--- io.github.petertrr:kotlin-multiplatform-diff
|    |    \--- kotlin
|    +--- io.kvision:kvision
|    |    +--- kotlin
|    |    +--- io.kvision:kvision-common-types
|    |    |    +--- kotlin
|    |    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json
|    |    |         +--- kotlin
|    |    |         \--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:kvision-bootstrap
|    |    +--- kotlin
|    |    +--- io.kvision:kvision (*)
|    |    +--- io.kvision:kvision-common-types (*)
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:kvision-bootstrap-icons
|    |    +--- kotlin
|    |    +--- io.kvision:kvision (*)
|    |    +--- io.kvision:kvision-common-types (*)
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:kvision-common-types (*)
|    +--- io.kvision:kvision-routing-navigo-ng
|    |    +--- kotlin
|    |    +--- io.kvision:kvision (*)
|    |    +--- io.kvision:kvision-common-types (*)
|    |    +--- io.kvision:navigo-kotlin-ng
|    |    |    \--- kotlin
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:kvision-state
|    |    +--- kotlin
|    |    +--- io.github.petertrr:kotlin-multiplatform-diff (*)
|    |    +--- io.kvision:kvision (*)
|    |    +--- io.kvision:kvision-common-types (*)
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:kvision-state-flow
|    |    +--- kotlin
|    |    +--- io.github.petertrr:kotlin-multiplatform-diff (*)
|    |    +--- io.kvision:kvision (*)
|    |    +--- io.kvision:kvision-common-types (*)
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:kvision-toastify
|    |    +--- kotlin
|    |    +--- io.kvision:kvision (*)
|    |    +--- io.kvision:kvision-common-types (*)
|    |    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    |    +--- org.jetbrains.kotlinx:atomicfu (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
|    +--- io.kvision:navigo-kotlin-ng (*)
|    +--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
|    +--- org.jetbrains.kotlinx:atomicfu (*)
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
|    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
|    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
+--- dev.gitlive:firebase-app (*)
+--- dev.gitlive:firebase-auth (*)
|    ^^^ This module requires symbol dev.gitlive.firebase.auth/FirebaseUser.displayName.<get-displayName>|-7122534302014937473[1].
+--- dev.gitlive:firebase-common (*)
+--- dev.gitlive:firebase-firestore (*)
+--- io.github.petertrr:kotlin-multiplatform-diff (*)
+--- io.kvision:kvision (*)
+--- io.kvision:kvision-bootstrap (*)
+--- io.kvision:kvision-bootstrap-icons (*)
+--- io.kvision:kvision-common-types (*)
+--- io.kvision:kvision-routing-navigo-ng (*)
+--- io.kvision:kvision-state (*)
+--- io.kvision:kvision-state-flow (*)
+--- io.kvision:kvision-toastify (*)
+--- io.kvision:navigo-kotlin-ng (*)
+--- org.jetbrains.kotlin:kotlinx-atomicfu-runtime (*)
+--- org.jetbrains.kotlinx:atomicfu (*)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core (*)
+--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
\--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)

(*) - dependencies omitted (listed previously)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDevelopmentExecutableKotlinJs'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

@shepeliev
Copy link
Contributor

@shubhamsinghshubham777 this workaround should solve it.

However, I think it should be fixed by PR here as KT-48836 has not been fixed since Kotlin 1.6 and there is no any ETA.

@shubhamsinghshubham777
Copy link
Author

Understood, thank you for the information. I should close this issue in that case ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants