@@ -4,6 +4,10 @@ import io.gitlab.arturbosch.detekt.DetektPlugin
4
4
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
5
5
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
6
6
import org.gradle.api.tasks.testing.logging.TestLogEvent
7
+ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
8
+ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
9
+ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
10
+ import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
7
11
8
12
@Suppress(" DSL_SCOPE_VIOLATION" )
9
13
plugins {
@@ -107,3 +111,32 @@ allprojects {
107
111
parent?.subprojects?.forEach { dependsOn(it.tasks.withType(taskClass)) }
108
112
}
109
113
}
114
+
115
+ /* *
116
+ * [Reference](https://github.com/square/okio/blob/55b7210fb3d52de07f4bc1122c5062e38df576d9/build.gradle.kts#L227-L248).
117
+ *
118
+ * Select a NodeJS version with WASI and WASM GC.
119
+ * https://github.com/Kotlin/kotlin-wasm-examples/blob/main/wasi-example/build.gradle.kts
120
+ */
121
+ plugins.withType<NodeJsRootPlugin > {
122
+ extensions.getByType<NodeJsRootExtension >().apply {
123
+ if (DefaultNativePlatform .getCurrentOperatingSystem().isWindows) {
124
+ // We're waiting for a Windows build of NodeJS that can do WASM GC + WASI.
125
+ nodeVersion = " 21.4.0"
126
+ } else {
127
+ // Reference:
128
+ // https://github.com/drewhamilton/Poko/blob/72ec8d24cf48a74b3d1125c94f0e625ab956b93f/build.gradle.kts#L17-L19
129
+ // WASM requires a canary Node.js version. This is the last v21 canary, and has both
130
+ // darwin-arm64 and darwin-x64 artifacts:
131
+ nodeVersion = " 21.0.0-v8-canary20231024d0ddc81258"
132
+ nodeDownloadBaseUrl = " https://nodejs.org/download/v8-canary"
133
+ }
134
+ }
135
+ // Suppress an error because yarn doesn't like our Node version string.
136
+ // warning You are using Node "21.0.0-v8-canary20231024d0ddc81258" which is not supported and
137
+ // may encounter bugs or unexpected behavior.
138
+ // error karma@6.4.2: The engine "node" is incompatible with this module.
139
+ tasks.withType<KotlinNpmInstallTask >().all {
140
+ args + = " --ignore-engines"
141
+ }
142
+ }
0 commit comments