korlibs / korge

KorGE Game Engine. Multiplatform Kotlin Game Engine

Home Page:https://korge.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support npm transitive dependencies with esbuild

soywiz opened this issue · comments

In the meantime this hack would do:

open class EsbuildCreateSymLink : DefaultTask() {
    private val realNodeModules = File(project.buildDir, "js/node_modules")
    private val linkNodeModulesProd = File(project.buildDir, "compileSync/js/main/productionExecutable/kotlin/node_modules")
    private val linkNodeModulesDev = File(project.buildDir, "compileSync/js/main/developmentExecutable/kotlin/node_modules")

    @TaskAction
    fun run() {
        for (linkNodeModules in listOf(linkNodeModulesProd, linkNodeModulesDev)) {
            linkNodeModules.parentFile.mkdirs()
            if (!Files.isSymbolicLink(linkNodeModules.toPath())) {
                Files.createSymbolicLink(linkNodeModules.toPath(), realNodeModules.toPath())
            }
        }
    }
}

tasks {
    val esbuildCreateSymLink by creating(EsbuildCreateSymLink::class) {
        dependsOn("kotlinNpmInstall")
    }

    val browserDebugEsbuild by getting {
        dependsOn(esbuildCreateSymLink)
    }
}