-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
59 lines (54 loc) · 1.56 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
plugins {
kotlin("js") version "1.9.0"
}
repositories {
mavenCentral()
google()
}
dependencies {
implementation(devNpm("wrangler", "^3.0.0"))
implementation(devNpm("@cloudflare/workers-types","^4.20230419.0"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.7.3")
// implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7")
}
//tasks.withType<KotlinCompile> {
// // Only works with K2 compiler!
// kotlinOptions.freeCompilerArgs += listOf()
//}
kotlin {
sourceSets.all {
languageSettings {
languageSettings.enableLanguageFeature("ExplicitBackingFields")
languageVersion = "2.1"
}
}
js {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xuse-k2"
freeCompilerArgs += "-Xcontext-receivers"
// freeCompilerArgs += "-XXLanguage:+ExplicitBackingFields"
}
}
nodejs {
}
binaries.executable()
}
}
val jsFile get() = buildDir.resolve("js/packages/${project.name}/kotlin/${project.name}.js")
tasks.create("buildSingleJs") {
group = "wrangler"
dependsOn(":compileProductionExecutableKotlinJs")
}
tasks.create("checkJsExist") {
group = "wrangler"
dependsOn(":compileProductionExecutableKotlinJs")
doLast {
require(jsFile.exists()) { "js file not found" }
}
}
tasks.create<Exec>("dev") {
group = "wrangler"
dependsOn(":buildSingleJs", ":checkJsExist")
commandLine("cmd","/c","wrangler dev -e development ${jsFile.absoluteFile} ")
}