It would be interesting to have a way to extend th...
# multiplatform
f
It would be interesting to have a way to extend the supported platforms of a library. For example, let's say that library X supports only
jvm
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.
Copy code
// 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"))
		}
	}
}
Copy code
// 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)
	}
}
👀 2
m
You are touching a critical issue with the concept of KMP here.