To use the IR compiler for our project, we make a small change to our adle(.kts) file. Making sure our Kotlin dependencies support Kotlin/JS IR.Fixing npm dependencies that use export default.Creating plain JavaScript objects for interaction with external components.Using external interface to define React properties ( RProps) and state ( RState) (instead of ( data) classes) and other areas of interoperation.Ultimately, it boiled down to running and testing the application (both in development and production mode), and keeping an eye on the following: We'll look at them in detail in the next sections. In the case of CodeQuiz, a number of modifications were necessary to get everything working. This stricter and more explicit control will help the compiler optimize your code more aggressively.īut, due to the nature of JavaScript being a dynamic runtime environment, some of these changes in behavior only appear during execution time. When using the IR compiler these mistakes become visible – it enforces proper, explicit interoperation between the world of Kotlin and the world of JavaScript (we call this the "Closed World" model). Unfortunately, this means that it was easy to rely on compiler-specific internal behavior – some things just happened to work, even though the compiler gave no guarantees that these things were supposed to work. a data class) from Kotlin code to the JavaScript world. This might require some adjustment at first, but will help write more predictable code that interoperates between Kotlin and JavaScript.Įspecially with code at the "boundary" between Kotlin and JavaScript, the legacy compiler was quite lenient – for example how it exported all symbols (e.g. Using it allows you to already test drive a bunch of new features, including TypeScript declaration generation, and profit from new optimizations like stronger DCE (and, as a result, smaller generated artifacts).īut it also means that you have to embrace its more strict rules regarding interoperation between Kotlin and JavaScript.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |