Skip to content

Commit

Permalink
Improve js build by moving node_modules to build dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sandwwraith committed Sep 12, 2018
1 parent 201ecd9 commit 7cb4c4c
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions runtime/js/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,26 @@ compileTestKotlin2Js {
kotlinOptions.sourceMap = true
}

task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) {
from compileKotlin2Js.destinationDir

configurations.testCompile.each {
from zipTree(it.absolutePath).matching { include '*.js' }
}

into "${buildDir}/node_modules"
}

node {
version = nodeVersion
download = true
nodeModulesDir = file(buildDir)
}

task populateNodeModules(type: Copy, dependsOn: [compileKotlin2Js]) {
from compileKotlin2Js.destinationDir
into "$node.nodeModulesDir/node_modules"

afterEvaluate {
configurations.testCompile.each {
if (it.absolutePath.endsWith(".jar")) {
from zipTree(it.absolutePath).matching {
include '*.js'
include '*.js.map'
}
}
}
}
}

// Workaround the problem with Node downloading:
Expand All @@ -72,13 +79,13 @@ repositories.whenObjectAdded {

task installQunit(type: NpmTask) {
inputs.property('qunitjsVersion', qunitjsVersion)
outputs.dir file('node_modules/qunitjs')
outputs.dir file("$node.nodeModulesDir/node_modules/qunitjs")

args = ['install', "qunitjs@${qunitjsVersion}"]
}

task runQunit(type: NodeTask, dependsOn: [compileTestKotlin2Js, populateNodeModules, installQunit]) {
script = file('node_modules/qunitjs/bin/qunit')
script = file("$node.nodeModulesDir/node_modules/qunitjs/bin/qunit")
args = [projectDir.toPath().relativize(file(compileTestKotlin2Js.outputFile).toPath())]
if (project.hasProperty("tests")) args += ["-f", project.property('tests')]
}
Expand Down

0 comments on commit 7cb4c4c

Please sign in to comment.