🦕Deno development with Kotlin.
// ========stub for Deno=======
import Kotlin from "https://jspm.dev/kotlin@1.4.0"
const module = {
exports: {}
};
function require(moduleName) {
if (moduleName === 'kotlin') {
return Kotlin
} else {
return {};
}
}
// ====== compiled JS code from Kotlin======
(function (_, Kotlin) {
// ...
}(module.exports, require('kotlin')));
export default module.exports;
$ ./gradlew deno
$ deno run --no-check build/deno/kotlin-deno-example.js
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.3.9")
import Kotlin from "https://jspm.dev/kotlin@1.4.0"
import KotlinxCoroutinesCore from "https://jspm.dev/kotlinx-coroutines-core@1.3.9"
//......
function require(moduleName) {
if (moduleName === 'kotlin') {
return Kotlin
} else if (moduleName === 'kotlinx-coroutines-core') {
return KotlinxCoroutinesCore;
} else {
return {};
}
}
As of Kotlin 1.4.0, the Kotlin/JS IR compiler has Alpha stability level. With Kotlin/JS IR compiler support, and and compiled JS code is more clean.
$ ./gradlew -t deno
$ deno run --unstable --watch --allow-read --no-check build/deno/kotlin-deno-example.js
Author: linux-china
Source Code: https://github.com/linux-china/kotlin-deno-example
#deno #nodejs #node #javascript #kotlin