Bernhard
10/02/2024, 11:45 AMtasks.register<Exec>("installOldJs") {
inputs.files(layout.projectDirectory.file("./oldsrc/package.json"))
outputs.dir(layout.projectDirectory.dir("./oldsrc/node_modules"))
workingDir = layout.projectDirectory.dir("oldsrc/").asFile
commandLine = listOf("yarn", "install")
}
tasks.register<Exec>("compileOldJs") {
mustRunAfter("installOldJs")
inputs.dir(layout.projectDirectory.dir("./oldsrc/src/"))
outputs.dir(layout.projectDirectory.dir("./oldsrc/dist/"))
workingDir = layout.projectDirectory.dir("oldsrc/").asFile
commandLine = listOf("yarn", "run", "build")
}
// inside kotlin block
val jsMain by getting {
resources.srcDirs(tasks.named("compileOldJs"))
dependencies {
implementation(project.dependencies.enforcedPlatform(libs.kotlin.wrappers))
implementation(libs.kotlin.wrappers.js)
implementation(libs.kotlin.plain.objects)
implementation(libs.kotlinx.html)
implementation(libs.kotlinx.coroutines.js)
implementation(libs.jsonschemavalidator.js)
api(libs.jquery)
}
}
but it seems that jsProductionExecutableCompileSync is tripping over the generated sourcemap:
Task :jsProductionExecutableCompileSync
Cannot rewrite paths in JavaScript source maps: Unsupported format. Contents should starts with `{"version":3,"file":"...","sources":[...],"sourcesContent":...`. Unknown key "mappings" at line 1 column 44 path $.mappings in `{"version":3,
Artem Kobzar
10/02/2024, 1:16 PMBernhard
10/02/2024, 2:29 PMIlya Goncharov [JB]
10/02/2024, 2:50 PMjs.map
file in resources should be okay.
But for now, I think you can use one of following ways:
1. Use your NPM package as a file dependency of Kotlin project. You can just use implementation(npm(file(…))
2. Use output of your compileOldJs
task as input to tasks jsProductionExecutableCompileSync
and jsDevelopmentExecutableCompileSync
, they have type IncrementalSyncTask
, and you can touch task.from.from(tasks.named("compileOldJs"))
Bernhard
10/02/2024, 2:51 PM