https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

janvladimirmostert

06/06/2020, 12:37 PM
Is it possible to mark certain classes / functions to be excluded from DCE? I'm trying to build a KotlinJS library that will be consumed by handwritten JavaScript and unless i specifically console.log that class, it gets removed by DCE
Copy code
@JsName("RoomState")
data class RoomState(
    val numberOfRooms: Int
)
Copy code
fun main() {
  console.log(RoomState::class)
}
which now allows me to do
Copy code
this.projectname.RoomState()
in pure JS, i exclude that console.log, RoomState is not available
c

christophsturm

06/06/2020, 1:01 PM
Copy code
kotlin {
js {dceTask {
    keep("ktor-ktor-io.\$\$importsForInline\$\$.<http://ktor-ktor-io.io.ktor.utils.io|ktor-ktor-io.io.ktor.utils.io>")
}
}
}
thats for ktor but you get the idea
j

janvladimirmostert

06/06/2020, 1:38 PM
that's awesome, let me experiment and see if it can handle wildcards, then i can just put the package in
seems like i need to do it for every single class that i'm exposing to the JS side, mmm, wonder if it can be achieved with a @NonDCE annotation or something
Thanks for the help, this is getting me in the right direction
4 Views