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

I think the JavaScript module is named “untitled2”, because that’s the project name, as well as the name of the .js file produced in build/js/packages. However, that doesn’t seem to work, or else I misunderstand how to use it.

Scenario 1.

I include the script in the body, and call the function I want from JavaScript’s main(), like so:

fun main() { apply("myCanvas") }

<canvas id="myCanvas" width="400" height="300"></canvas>
<script src="untitled2.js">

Everything works fine.

Scenario 2.

I include the script in the header:

<head> <!-- standard boilerplate omitted -->
<script src="untitled2.js"></script>

When I try to reference this in my HTML file:

<canvas id="myCanvas" width="400" height="300"></canvas>
<button type="button" id="button1" onclick="untitled2.apply('myCanvas')">Plot it</button>

the JavaScript debugger console reports, Can't find variable: untitled2. So apparently that isn’t the module name. Omitting untitled2 also doesn’t work.

How do I determine the module name – or – how do I import it properly? I have read the usual suspects cited here.

(I hope it’s allowed to bump this topic in the hope that someone notices.)