Is there any update on variant support in Amper? W...
# amper
s
Is there any update on variant support in Amper? When is it going to be implemented?
a
Hi Sabeeh, haven’t planned specifically yet; could you remind how you want to use the variants?
s
@amakeev I'm working on library https://github.com/fleeksoft/ksoup/tree/develop in which i want to create two variants of library using kotlinx-io and korlibs both are IO libraries. Right now I"m trying to do create a placeholder module with functions with body TODO() and then those are replace with real functions in other module. This is working fine in jvm and ios but not in js in js it always run code from placeholder module and if i set that module compile-only then it give error
Copy code
e: KLIB resolver: Could not find "ksoup:ksoup-core-placeholder" in
a
Thanks! Does it mean that you want these library variants be published and consumer independently? I'm asking because the main known use-cases for the variants are applications, not library publication. Thus I can't give any estimations since we haven't considered such a scenario yet. Have you considered using separate 'engine' modules instead of variants, just like Ktor does?
s
@amakeev I want to publish a library with two variants: one
ksoup-korlib
which use korlib for IO and the other
ksoup-kotlinx
, which use kotlinx-io, so users can choose between them. The concept of using Ktor engine modules is one solution that could work. However, my main issue is that it would require changing the current APIs. Right now, all the publish functions are static and can be accessed directly through the
Ksoup
object class. To follow the engine module approach, I would need to add library initialization code, and users would need to create an instance of the library to use it. This would break the code for users upgrading to the new version. Ideally, I’d like to create an API module with engine-dependent function bodies set as
TODO()
, which could then be replaced at compile time with the original module for
ksoup-korlib
or
ksoup-kotlinx
. I’ve already implemented this successfully for JVM, but it hasn’t worked for Native or JS. I'm getting compiler error: e: KLIB resolver: Could not find "ksoup:ksoup-core-placeholder" in I will create simple sample code and send it to you later.
@amakeev i just opened issue regarding this on yourtrack: https://youtrack.jetbrains.com/issue/KT-70727