Debugging
You can easily debug KVision applications in most modern browsers (e.g. Chrome or Firefox), which support source maps generated by Kotlin/JS compiler. Source maps allow you to see Kotlin source code in the browser "Sources" panel. You can see line numbers, step through your code, set breakpoints and watch variable values just like with plain JavaScript.
You can also debug KVision application directly in IntelliJ IDEA Ultimate by creating new "JavaScript Debug" configuration pointing to http://localhost:3000 url.
Note: Source maps are disabled by default in all KVision template projects, because the development cycle (hot reload) is a lot faster without them. To enable source maps you need to remove line sourceMaps = false
from your build.gradle.kts
file and remove line config.devtool = 'eval-cheap-source-map'
from webpack.config.d/webpack.js
file.
Console.log
Some UI interactions may be tricky to handle with a debugger, and so being able to fall back to console logging is useful. We find it useful to create a debug function, which is turned on and off with a global boolean.
Last updated