firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

Incompatible with JS IR because of @JsName("default")

Open SalomonBrys opened this issue 3 years ago • 0 comments
trafficstars

The following Kotlin/JS source files use @JsName("default") to access JS module default object:

When compiled with the JS IR compiler, this produces a WebPack failure:

ERROR in ./kotlin/kotlin_dev_gitlive_firebase_firestore.js 10:15

Module parse failed: Unexpected token (10:15)
File was processed with these loaders:
 * ../../node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|       throw new Error("Error loading module 'kotlin_dev_gitlive_firebase_firestore'. Its dependency 'firebase/compat/app' was not found. Please, check whether 'firebase/compat/app' is loaded prior to 'kotlin_dev_gitlive_firebase_firestore'.");
|     }
>     if (typeof default === 'undefined') {
|       throw new Error("Error loading module 'kotlin_dev_gitlive_firebase_firestore'. Its dependency 'firebase/compat/firestore' was not found. Please, check whether 'firebase/compat/firestore' is loaded prior to 'kotlin_dev_gitlive_firebase_firestore'.");
|     }

If useCommonJs() is set, the error becomes:

ERROR in ./kotlin/kotlin_dev_gitlive_firebase_firestore.js 1:54

Module parse failed: Unexpected keyword 'default' (1:54)
File was processed with these loaders:
 * ../../node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
> (function (_, $module$firebase_compat_app_2537183240, default, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_dev_gitlive_firebase_common, kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core, kotlin_dev_gitlive_firebase_app) {
|   //region block: imports
|   var default_0 = $module$firebase_compat_app_2537183240.default;

This looks like a known issue which is supposed to be fixed...

Do you know a workaround?

Btw: I need to use JS/IR because I'm writing a Kotlin/JS Web Compose app.

SalomonBrys avatar Jun 07 '22 18:06 SalomonBrys