ionspin / kotlin-multiplatform-bignum

A Kotlin multiplatform library for arbitrary precision arithmetics
Apache License 2.0
339 stars 40 forks source link

Add support for wasm target #273

Closed gsteckman closed 6 months ago

gsteckman commented 7 months ago

Is your feature request related to a problem? Please describe. Kotlin wasm is now alpha, has higher performance than js, and appears to be the strategic direction for JetBrains supporting Kotlin on the browser (e.g. with Compose Multiplatform).

Describe the solution you'd like Support for the wasmJs target

Describe alternatives you've considered Porting applications to not depend on bignum

joffrey-bion commented 6 months ago

I really wish this was added. Does it represent a lot of work to add this target to bignum?

ionspin commented 6 months ago

Hey @joffrey-bion I just didn't have time to get to it, you could try to do it yourself and send a pull request, it should be as simple as adding new target, but from past experience it's always a bit more finagling to get everything to work.

joffrey-bion commented 6 months ago

I wanted to do this, but there were lots of conditionals around targets, the goal of which I didn't understand, so I wasn't sure where to add this one.

I figured it was easier to ask before even trying, because if a whole implementation for this target is required, I would leave that to you anyway.

ionspin commented 6 months ago

I wanted to do this, but there were lots of conditionals around targets, the goal of which I didn't understand, so I wasn't sure where to add this one.

Yeah, this is due for a cleanup, mostly it was workarounds to get the it to compile on previous versions of Kotlin multiplatform.

I figured it was easier to ask before even trying, because if a whole implementation for this target is required, I would leave that to you anyway.

No need for platform implementation, it's pure common source kotlin, so in theory it's just adding targets. In practice, and especially with experimental targets, not so much :)

I'm looking into adding wasmJs right now, seems I might get it to work, I'll get back to you.

joffrey-bion commented 6 months ago

Thanks a lot! And sorry not to have contributed this :)

ionspin commented 6 months ago

WasmJS for browser should be available in SNAPSHOT. Happy holidays!

joffrey-bion commented 6 months ago

Hey @ionspin, are you sure it was published? I can't find the bignum-wasm-js artifact in the snapshots repository (and Gradle can't either):

   > Could not find com.ionspin.kotlin:bignum-wasm-js:0.3.9-SNAPSHOT.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/ionspin/kotlin/bignum-wasm-js/0.3.9-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/com/ionspin/kotlin/bignum-wasm-js/0.3.9-SNAPSHOT/bignum-wasm-js-0.3.9-SNAPSHOT.pom
       - https://oss.sonatype.org/content/repositories/snapshots/com/ionspin/kotlin/bignum-wasm-js/0.3.9-SNAPSHOT/maven-metadata.xml
       - https://oss.sonatype.org/content/repositories/snapshots/com/ionspin/kotlin/bignum-wasm-js/0.3.9-SNAPSHOT/bignum-wasm-js-0.3.9-SNAPSHOT.pom
ionspin commented 6 months ago

Let me check.

ionspin commented 6 months ago

Deployment script was missing publish to snapshot task, sorry about that. Should be up now. https://oss.sonatype.org/content/repositories/snapshots/com/ionspin/kotlin/bignum-wasm-js/

joffrey-bion commented 6 months ago

Thank you so much for the very quick response, it works now 🙏

sureshg commented 5 months ago

@ionspin thanks for adding the wasmjs support... any plans to release 0.3.10 soon to central?

gsteckman commented 5 months ago

Thanks for adding this. Is there new work required for serialization support as well, or only adding the build target?

ionspin commented 5 months ago

@sureshg I might have some time this weekend to work on the library. I need to take care of #277 before releasing, so no promises :)

@gsteckman Off the top of my head, just adding the targets, I'll try it out over the weekend as well.

ionspin commented 5 months ago

@sureshg 0.3.9 with wasmJs is out, probably will take an hour or two for it to appear on maven.

@gsteckman I forgot, but it seems I have already added wasmJs to serialization library. Now it's also released as 0.3.9, let me know if you have any problems with serialization.