spierce7
01/19/2025, 11:45 PMprocess.env
is necessary, but the interop of the js
function requires a static string, so I'm not seeing how to properly access it via js interop.ephemient
01/19/2025, 11:47 PMfun getenv(name: String): String = js("process.env[name] ?? ''")
spierce7
01/20/2025, 12:39 AMfun getenv(name: String): String? {
return js("process?.env?.[name]")
}
Calls to 'js(code)' should be a single expression inside a top-level function body or a property initializer in Kotlin/Wasm.
This is just a function in a file, so I'm not seeing how we aren't meeting this criteria.ephemient
01/20/2025, 12:49 AM=
and I think ?
return doesn't workMichael Paus
01/20/2025, 9:34 AMwasmJs
😱Oleg Yukhnevich
01/20/2025, 9:42 AMYoonho Aaron Kim
05/22/2025, 3:23 AM// commonMain
expect val SERVER_DOMAIN: String
// wasmJsMain
actual val SERVER_DOMAIN: String
get() {
return js("process.env[KTOR_HOST]")
}
Build Fail: 'js(code)' should be a single expression inside a top-level function body or a property initializer in Kotlin/Wasm.
ephemient
05/22/2025, 3:33 AMprivate fun getenv(name: String): String? = js("process.env[name]")
actual val SERVER_DOMAIN: String
get() = getenv("KTOR_HOST")!!
Yoonho Aaron Kim
05/22/2025, 3:58 AM