koin icon indicating copy to clipboard operation
koin copied to clipboard

Wasm throws exceptions using koin on IPv4 [_this.randomUUID is not a function]

Open crowforkotlin opened this issue 1 year ago • 0 comments

ERROR
_this.randomUUID is not a function
TypeError: _this.randomUUID is not a function
    at kotlin.uuid.randomUUID_$external_fun (webpack-internal:///./kotlin/ComposeApp.uninstantiated.mjs:182:69)
    at <MordecaiX:composeApp>.kotlin.uuid.randomUUID_$external_fun__externalAdapter (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[13386]:0x48c6ec)
    at <MordecaiX:composeApp>.kotlin.uuid.secureRandomUuid (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[13384]:0x48c6bf)
    at <MordecaiX:composeApp>.kotlin.uuid.Companion.random (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[11818]:0x47d234)
    at <MordecaiX:composeApp>.org.koin.mp.generateId (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[63113]:0x8d55a6)
    at <MordecaiX:composeApp>.org.koin.core.module.Module.<init> (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[62929]:0x8d0f13)
    at <MordecaiX:composeApp>.org.koin.dsl.module (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[63094]:0x8d52d2)
    at <MordecaiX:composeApp>.org.koin.dsl.module$default (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[63095]:0x8d531c)
    at <MordecaiX:composeApp>.com.crow.mordecaix.model.di.<init properties ViewModelModule.kt> (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[68699]:0x94bde0)
    at <MordecaiX:composeApp>.com.crow.mordecaix.model.di.<get-viewmodelModule> (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[68690]:0x94bbcf)
commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)


            implementation(libs.jetbrains.kotlinx.coroutines)
            implementation(libs.jetbrains.kotlinx.collections)
            implementation(libs.jetbrains.lifecycle.viewmodel)
            implementation(libs.jetbrains.lifecycle.runtime.compose)
            implementation(libs.jetbrains.compose.materialWindow)
            implementation(libs.jetbrains.compose.material3.adaptive)
            implementation(libs.jetbrains.compose.material3.adaptive.layout)
            implementation(libs.jetbrains.compose.material3.adaptive.navigation)
            implementation(libs.jetbrains.androidx.navigation)
            implementation(libs.koin.core)
            implementation(libs.koin.compose)
            implementation(libs.koin.compose.viewmodel)
            implementation(libs.koin.compose.viewmodel.navigation)
            implementation(libs.ktor.client.core)

            implementation(libs.kotlinx.datetime)
        }
wasmJs {
        moduleName = "ComposeApp"
        browser {
            val projectDirPath = project.projectDir.path
            commonWebpackConfig {
                outputFileName = "composeApp.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    static = (static ?: mutableListOf()).apply {
                        // Serve sources to debug inside browser
                        add(projectDirPath)
                    }
                }
            }
        }
        binaries.executable()
    }
compose-plugin = "1.7.0-rc01"
kotlin = "2.0.20"
koin = "4.0.0"

// ============================================
@OptIn(ExperimentalComposeUiApi::class)
fun main() {
    initializeApplication()
    ComposeViewport(document.body!!) {
        App()
    }
}
@Composable
fun App() {
    MordecaiXTheme {
        MordecaiXApp()
    }
}
@Composable
fun MordecaiXApp() { }
// ============================================

fun initializeApplication() {
    startKoin {
        modules(
            viewmodelModule, 
        )
    }
}

val viewmodelModule = module {
    viewModel { AppViewModel() }
}
class AppViewModel : ViewModel() {}
// ============================================

./gradlew wasmJsBrowerRun It's normal to use localhost access

startkoin is normal, it is also normal when I delete modules, and there is a problem when modules are added

crowforkotlin avatar Oct 12 '24 02:10 crowforkotlin