Grantas33
05/24/2020, 7:29 PMjs {
useCommonJs()
produceExecutable()
browser {}
}
Is there a way to compile typescript declarations in commonJs format in kotlin multiplatform 1.4-M1?Derek Ellis
05/24/2020, 8:03 PMJustin
05/24/2020, 8:29 PMDerek Ellis
05/24/2020, 8:37 PMtarget {
browser {
webpackTask {
output.libraryTarget = COMMONJS
//output.libraryTarget = "commonjs" // alternative
}
}
}
Derek Ellis
05/24/2020, 8:37 PMjs
instead of target
Justin
05/24/2020, 8:40 PMkotlin {
{...}
js("js") {
nodejs()
compilations["main"].defaultSourceSet.dependencies {
implementation(kotlin("stdlib-js", kotlin_version))
}
}
}
Derek Ellis
05/24/2020, 8:42 PMnodejs
has a webpackTask
thing, but this will also work and apply it to all js targets (it's what useCommonJs
does under the hood).
compilations.all {
it.compileKotlinTask.kotlinOptions {
moduleKind = "commonjs"
sourceMap = true
sourceMapEmbedSources = null
}
}
Justin
05/24/2020, 9:11 PM> Task :compileProductionKotlinJs FAILED
e: java.lang.AssertionError: Properties without fields are not supported com.project.models.Flow.Companion_instance
This is `Flow`:
@Serializable
@CommonJsExport
data class Flow(
val id: String,
val variables: Variables,
val locales: Locales,
val data: FlowData
)
Justin
05/24/2020, 9:12 PMDerek Ellis
05/24/2020, 10:06 PMJustin
05/24/2020, 11:26 PMJustin
05/24/2020, 11:27 PM