Starting with Kotlin 1.3.60, the Kotlin/JS Gradle plugin automatically generates source maps for our builds. These enable support for debugging our code using browser development tools. To get started debugging our code, execute the
run task in a project using the JS Gradle plugin, or
browserDevelopmentRun in a multiplatform project. Once the development server is running, we can start our debugging session from the browser.
To begin debugging, let's navigate to the page and launch the developer tools of our browser (for example by right-clicking and selecting the Inspect action). If our program is logging information to the console, we can navigate to the Console tab to see this output. Depending on our browser and its developer tools, these logs will also reference the Kotlin source files they originate from: