JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.42k stars 1.12k forks source link

TypeError `x is undefined` / `stringLength` when using `values/strings.xml` compose resources on `wasmJs` target #4171

Open rjaros opened 5 months ago

rjaros commented 5 months ago

Describe the bug An exception is thrown when trying to get string resources on wasmJs.

Uncaught (in promise) TypeError: x is undefined
    stringLength webpack-internal:///./kotlin/kilua-examples-resources-wasm-js.uninstantiated.mjs:30
kilua-examples-resources-wasm-js.uninstantiated.mjs:26

Affected platforms Select one of the platforms below:

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Checkout https://github.com/rjaros/kilua/
  2. Run ./gradlew -t :examples:resources:wasmJsRun
  3. Open http://localhost:8080
  4. Click Test compose resources button
  5. Check the browser console
  6. See error

Expected behavior No error. The Compose Resources App string printed in console.

Additional context The application source code is here: https://github.com/rjaros/kilua/blob/main/examples/resources/src/commonMain/kotlin/main.kt It works ok when compiled to js target.

rjaros commented 3 months ago

On Kotlin 2.0.0-RC1 Wasm target and Compose 1.6.2 it still doesn't work, but the error message is different and even less telling :

JsException: Exception was thrown while running JavaScript code