What is the name of my Kotlin-generated JavaScript module?

I have encountered and a related problem, which may well have been the same thing. When I tried to produce a BrowserProductionRun, the resulting JavaScript files lacked any references to anything but the main() function.

I am writing a JavaScript library that I want to call from an HTML file, so I have a number of functions that aren’t called within the module itself, but will be called from JavaScript. Unfortunately, Kotlin’s Dead Code Elimination was eliminating those functions. As per this page, simply adding

dceTask {
   keep("myModule.myFunction")
}

to build.gradle.kts did the trick.

Is this the only way to prevent the compiler from eliminating functions it thinks are pointless?

1 Like