Kotlin 1.3.40 发布,为 Kotlin/JS 增加对主流打包工具的支持

Kotlin 1.3.40 已发布,除了针对稳定性以及工具方面的改进外,此版本值得关注的更新包括:

  • 为 Kotlin/JS 提供 Gradle 对 NPM, Yarn 和 Webpack 的支持
  • 针对多平台项目改进测试运行器
  • 新的类型接口
  • 改进 Kotlin/Native 的性能和互操作性
  • 一些添加到标准库的实验阶段新函数
  • ……

简单介绍如下:

对 NPM 和 Webpack 的实验性支持

此功能有助于简化使用 Node.js、NPM、Yarn 或 Webpack 的 JavaScript 项目的开发。团队为 Kotlin/JS 和多平台 Gradle 插件添加了辅助任务以简化集成的过程。此插件会为项目生成一个临时的 package.json,它将下载并使用 Yarn 来自动管理 NPM 依赖,Webpack 将在幕后使用,以加入所有依赖项。

该插件将 Gradle 项目中声明的所有 Kotlin/JS 依赖项附加到自动维护的 node_modules 文件夹中。现在也支持在 Gradle 脚本中添加 NPM 依赖。

dependencies {
    implementation(npm("react", "16.8.3"))
}

标准库中的实验性函数

  • ByteArray.decodeToString 和 String.encodeToByteArray
  • CharArray.concatToString 和 String.toCharArray

还有一个添加在 JVM 之上的函数为 capitalize,它将Locale对象作为参数。

升级方法

  • In Maven, Gradle, and npm: Use 1.3.40 as the version for the compiler and the standard library. See the docs here.
  • In IntelliJ IDEA and Android Studio: Update the Kotlin plugin to version 1.3.40. Use Tools | Kotlin | Configure Kotlin Plugin Updates and click the “Check for updates now” button.
  • In Eclipse: Install the plugin using Marketplace.
  • The command-line compiler can be downloaded from the Github release page.

猜你喜欢

转载自www.oschina.net/news/107637/kotlin-1-3-40-released