franztesca
12/02/2023, 12:32 AMjvm
and native
, but I also need to support js. Library X has only a tiny part that is platform-specific (e.g. 1 class), and I know how to implement it for JS. However, the owners of X are not interested in maintaining also the JS target, as that is not in their goals. The current solution is to fork the library and keep a separate copy, which is quite cumbersome.
It would be nice instead if I could just add a single module e.g. X-js
, which extends X to support also that platform. X-js
will have a special dependency on X, indicating that it is extending that library with a new target, and it will just need to provide the actual implementations for the expect definitions of X.
e.g.
// My project that needs X library for all jvm, native, js
kotlin {
commonMain.dependencies {
implementation(X) {
// Sample syntax to declare that we are extending the platforms of X using X-js
platformExtension(project(":X-js"))
}
}
}
// Project X-js
kotlin {
js()
commonMain.dependencies {
// Sample syntax to declare that we are providing platform implementations for the common code of X
extends(X)
}
}
Michael Paus
12/02/2023, 10:20 AM