Gradle, Kotlin/JS: enable source maps by default, get it working on tests.

Publish kotlin-test-nodejs-runner separately from kotlin-gradle-plugin.
This commit is contained in:
Sergey Rostov
2019-03-25 15:39:03 +03:00
parent a4cbec64b7
commit 0e0c78317d
17 changed files with 586 additions and 135 deletions
@@ -1,10 +1,27 @@
import com.moowork.gradle.node.yarn.YarnTask
description = "Simple Kotlin/JS tests runner with TeamCity reporter"
plugins {
id("base")
id("com.moowork.node") version "1.2.0"
}
val default = configurations.getByName(Dependency.DEFAULT_CONFIGURATION)
val archives = configurations.getByName(Dependency.ARCHIVES_CONFIGURATION)
default.extendsFrom(archives)
plugins.apply("maven")
convention.getPlugin(MavenPluginConvention::class.java).also {
it.conf2ScopeMappings.addMapping(MavenPlugin.RUNTIME_PRIORITY, archives, Conf2ScopeMappingContainer.RUNTIME)
}
dependencies {
archives(project(":kotlin-test:kotlin-test-js"))
}
node {
version = "11.9.0"
download = true
@@ -25,25 +42,43 @@ tasks {
setWorkingDir(projectDir)
args = listOf("build")
inputs.dir(projectDir.resolve("src"))
outputs.file(projectDir.resolve("lib/kotlin-test-nodejs-runner.js"))
inputs.dir("src")
inputs.files(
"cli.ts",
"nodejs-source-map-support.js",
"package.json",
"rollup.config.js",
"tsconfig.json",
"yarn.lock"
)
outputs.dir("lib")
}
create<Delete>("cleanYarn") {
group = "build"
delete = setOf(
projectDir.resolve("node_modules"),
projectDir.resolve("lib"),
projectDir.resolve(".rpt2_cache")
"node_modules",
"lib",
".rpt2_cache"
)
}
getByName("clean").dependsOn("cleanYarn")
}
val jar = tasks.create<Jar>("jar") {
dependsOn("yarnBuild")
from(projectDir.resolve("lib"))
}
artifacts {
add("archives", projectDir.resolve("lib/kotlin-test-nodejs-runner.js")) {
builtBy("yarnBuild")
add(
"archives",
jar.archiveFile.get().asFile
) {
builtBy(jar)
}
}
}
publish()
@@ -0,0 +1 @@
require('source-map-support').install();
@@ -14,7 +14,8 @@
"build": "rimraf lib/* && rollup -c rollup.config.js"
},
"dependencies": {
"@types/node": "^10.12.21"
"@types/node": "^10.12.21",
"source-map-support": "^0.5.11"
},
"devDependencies": {
"copyfiles": "^2.1.0",
@@ -11,49 +11,66 @@ export default [
output: {
file: 'lib/kotlin-test-nodejs-runner.js',
format: 'cjs',
banner: '#!/usr/bin/env node'
banner: '#!/usr/bin/env node',
sourcemap: true
},
plugins: [
nodeResolve({
jsnext: true,
main: true
}),
jsnext: true,
main: true
}),
commonjs(),
typescript({
tsconfig: "tsconfig.json"
}),
tsconfig: "tsconfig.json"
}),
uglify({
sourcemap: true,
compress: {
// hoist_funs: true,
// hoist_vars: true,
toplevel: true,
unsafe: true,
dead_code: true,
global_defs: {
DEBUG: false,
VERSION: pckg.version,
BIN: Object.keys(pckg.bin)[0],
DESCRIPTION: pckg.description
}
},
mangle: {
properties: {
keep_quoted: true,
reserved: [
"argv", "hrtime",
"kotlin_test", "kotlin", "setAdapter", "setAssertHook_4duqou$",
"suite", "test",
"stack"
]
},
toplevel: true,
},
// output: {
// beautify: true
// }
}),
// sourceMaps()
sourcemap: true,
compress: {
// hoist_funs: true,
// hoist_vars: true,
toplevel: true,
unsafe: true,
dead_code: true,
global_defs: {
DEBUG: false,
VERSION: pckg.version,
BIN: Object.keys(pckg.bin)[0],
DESCRIPTION: pckg.description
}
},
mangle: {
properties: {
keep_quoted: true,
reserved: [
"argv", "hrtime",
"kotlin_test", "kotlin", "setAdapter", "setAssertHook_4duqou$",
"suite", "test",
"stack"
]
},
toplevel: true,
}
})
]
},
{
input: './nodejs-source-map-support.js',
external: ['path', 'fs', 'module'],
output: {
file: 'lib/kotlin-nodejs-source-map-support.js',
format: 'cjs',
sourcemap: true
},
plugins: [
nodeResolve({
jsnext: true,
main: true
}),
commonjs(),
uglify({
compress: true,
sourcemap: true
})
]
}
]
@@ -2,10 +2,8 @@
"compilerOptions": {
"target": "es5",
"module": "ESNext",
// "declaration": true,
// "outDir": "./lib",
"strict": true,
// "sourceMap": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"inlineSourceMap": true
},
@@ -94,6 +94,11 @@ braces@^1.8.2:
preserve "^0.2.0"
repeat-element "^1.1.2"
buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
builtin-modules@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.0.0.tgz#1e587d44b006620d90286cc7a9238bbc6129cab1"
@@ -889,12 +894,20 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0"
urix "^0.1.0"
source-map-support@^0.5.11:
version "0.5.11"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.11.tgz#efac2ce0800355d026326a0ca23e162aeac9a4e2"
integrity sha512-//sajEx/fGL3iw6fltKMdPvy8kL3kJ2O3iuYlRoT3k9Kb4BjOoZ+BZzaNHeuaruSt+Kf3Zk9tnfAQg9/AJqUVQ==
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map-url@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=
source-map@~0.6.1:
source-map@^0.6.0, source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==