Oliver.O
07/06/2023, 10:12 AMCannot find module '@js-joda/core'
Details in 🧵.Oliver.O
07/06/2023, 10:16 AMrepositories {
mavenCentral()
maven("<https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental>")
}
and in `sourceSets`:
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0-wasm0")
}
}
Then `Simple.kt`:
import kotlinx.browser.document
import kotlinx.datetime.Clock
import kotlinx.dom.appendText
import org.w3c.dom.HTMLDivElement
fun main() {
(document.getElementById("warning") as HTMLDivElement).style.display = "none"
document.body?.appendText("Hello, ${greet()}!")
}
fun greet() = "world at ${Clock.System.now()}"
Any ideas?bashor
07/06/2023, 6:50 PMwebpack.config.d/
, so it should help to workaround the issuebashor
07/06/2023, 6:51 PMOliver.O
07/06/2023, 10:19 PMhackImport.js
works well for kotlin-wasm-examples/browser-example
.
With kotlin-wasm-examples/compose-jetsnack/web
, it is not sufficient:
Uncaught TypeError: Failed to resolve module specifier '@js-joda/core'
at instantiate (jetsnackwasmapp.uninstantiated.mjs:17:38)
at load.mjs:7:11
The main difference seems to be that compose-jetsnack distributes artifacts across two build directories:
• kotlin-wasm-examples/compose-jetsnack/build
• kotlin-wasm-examples/compose-jetsnack/web/build
I could not find out how to instruct webpack where to look for the npm module. And there seems to be no Compose compiler plugin working with Kotlin 1.9.20 yet.darkmoon_uk
07/08/2023, 5:51 AMdarkmoon_uk
07/08/2023, 5:52 AM1.9.0
with K 1.4.0-dev-wasm08
darkmoon_uk
07/08/2023, 7:05 AM<projectRoot>/webpack.config.d/hackImport.js
was aggregated into <projectRoot>/build/js/packages/jetsnackwasmapp/webpack.config.js
but for some reason jodatime module still isn't loaded, in the browser: TypeError: Failed to resolve module specifier '@js-joda/core'
darkmoon_uk
07/08/2023, 8:10 AMskia
for Compose.darkmoon_uk
07/08/2023, 8:11 AMjs-joda
- wondering how kotlinx.datetime
Dev expected this wasm release to work 🤔Oliver.O
07/08/2023, 8:27 AMdarkmoon_uk
07/08/2023, 10:37 AMdarkmoon_uk
07/08/2023, 11:56 AMdarkmoon_uk
07/08/2023, 12:04 PM1.9.0
WASM + Compose. Probably requires either a good understanding of webpack, which I don't have, or a 1.9.20
WASM compatible Compose compiler, which doesn't exist. Patience, then 😑Oliver.O
07/08/2023, 12:10 PMkotlinCompilerPlugin.set(composeVersion)
with kotlinCompilerPlugin.set("org.jetbrains.kotlin.experimental.compose:compiler:1.9.20-dev-5418")
in all build.gradle.kts
,
• use Kotlin version 1.9.20-dev-5418
,
• add the repo maven("<https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev>")
.
With the above, I got
Module "com.example:web" has a reference to symbol androidx.compose.ui.window/CanvasBasedWindow|315412121457049229[0]. Neither the module itself nor its dependencies contain such declaration.
Have to leave now, going to the beach. 🏖️🙂darkmoon_uk
07/08/2023, 12:11 PMOliver.O
07/08/2023, 12:12 PMdarkmoon_uk
07/08/2023, 12:13 PMdarkmoon_uk
07/08/2023, 12:14 PMbashor
07/10/2023, 9:41 PM@js-joda
dir from build/js/node_modules/
to build/js/packages/jetsnackwasmapp/kotlin/
And add to index.html before <script type="application/javascript" src="skiko.js"></script>
following:
<script type="importmap">
{
"imports": {
"@js-joda/core": "./@js-joda/core/dist/js-joda.esm.js"
}
}
</script>
Oliver.O
07/10/2023, 9:45 PMdarkmoon_uk
07/10/2023, 11:31 PMOliver.O
07/11/2023, 3:58 PMapplyBinaryen()
does not yet work (see comment in build.gradle.kts
), but I've tried to use it merely for completeness as the application is somewhat tiny.bashor
07/11/2023, 5:09 PMapplyBinaryen {
binaryenArgs = mutableListOf(
"--enable-nontrapping-float-to-int",
"--enable-gc",
"--enable-reference-types",
"--enable-exception-handling",
"--enable-bulk-memory",
"--hybrid"
"--inline-functions-with-loops",
"--traps-never-happen",
"--fast-math",
"-O1",
"-c", // Run passes while binary size decreases
)
}
darkmoon_uk
07/12/2023, 12:02 AM