October 2021
Intermediate to advanced
500 pages
16h 23m
English
Your first step is to declare a new target in your code for JavaScript. This will once again involve updating your build.gradle file.
Listing 26.1 Declaring a JavaScript target (build.gradle)
...
kotlin {
jvm()
macosX64() {
binaries {
executable()
}
}
js {
browser()
binaries {
executable()
}
}
sourceSets {
...
}
}
...
The only thing new here is the browser function call. This specifies that you intend to run your JavaScript inside a browser. You can also use nodejs to have your project compile for Node.js, a standalone JavaScript runtime environment commonly used to build web servers.
Perform a Gradle sync after making these changes.
Once again, your project will no longer compile, because ...
Read now
Unlock full access