Windows source-map-loading with absolute paths
This commit is contained in:
+12
-2
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Devtool
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.reportsDir
|
||||
import org.slf4j.Logger
|
||||
import java.io.File
|
||||
@@ -150,7 +149,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
val webpackConfigWriter = KotlinWebpackConfig(
|
||||
configDirectory = project.projectDir.resolve("webpack.config.d").takeIf { it.isDirectory },
|
||||
sourceMaps = true,
|
||||
devtool = Devtool.INLINE_SOURCE_MAP,
|
||||
devtool = null,
|
||||
export = false,
|
||||
progressReporter = true,
|
||||
progressReporterPathFilter = nodeJs.rootPackageDir.absolutePath
|
||||
@@ -164,6 +163,17 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
||||
it.appendln("function createWebpackConfig() {")
|
||||
|
||||
webpackConfigWriter.appendTo(it)
|
||||
//language=ES6
|
||||
it.appendln(
|
||||
"""
|
||||
(function() {
|
||||
const webpack = require('webpack');
|
||||
config.plugins.push(new webpack.SourceMapDevToolPlugin({
|
||||
moduleFilenameTemplate: "[absolute-resource-path]"
|
||||
}))
|
||||
})();
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
it.appendln(" return config;")
|
||||
it.appendln("}")
|
||||
|
||||
+3
-4
@@ -26,7 +26,7 @@ data class KotlinWebpackConfig(
|
||||
val bundleAnalyzerReportDir: File? = null,
|
||||
val reportEvaluatedConfigFile: File? = null,
|
||||
val devServer: DevServer? = null,
|
||||
val devtool: Devtool = Devtool.EVAL_SOURCE_MAP,
|
||||
val devtool: Devtool? = Devtool.EVAL_SOURCE_MAP,
|
||||
val showProgress: Boolean = false,
|
||||
val sourceMaps: Boolean = false,
|
||||
val export: Boolean = true,
|
||||
@@ -79,8 +79,7 @@ data class KotlinWebpackConfig(
|
||||
|
||||
enum class Devtool(val code: String) {
|
||||
EVAL_SOURCE_MAP("eval-source-map"),
|
||||
SOURCE_MAP("source-map"),
|
||||
INLINE_SOURCE_MAP("inline-source-map")
|
||||
SOURCE_MAP("source-map")
|
||||
}
|
||||
|
||||
fun save(configFile: File) {
|
||||
@@ -197,7 +196,7 @@ data class KotlinWebpackConfig(
|
||||
use: ["kotlin-source-map-loader"],
|
||||
enforce: "pre"
|
||||
});
|
||||
config.devtool = '${devtool.code}';
|
||||
config.devtool = ${devtool?.code?.let { "'$it'" } ?: false};
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
@@ -1,38 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
const util = require('util');
|
||||
const resolve = require('url').resolve;
|
||||
|
||||
const escapeMessage = function (message) {
|
||||
if (message === null || message === undefined) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return message.toString()
|
||||
.replace(/\|/g, '||')
|
||||
.replace(/'/g, "|'")
|
||||
.replace(/\n/g, '|n')
|
||||
.replace(/\r/g, '|r')
|
||||
.replace(/\u0085/g, '|x')
|
||||
.replace(/\u2028/g, '|l')
|
||||
.replace(/\u2029/g, '|p')
|
||||
.replace(/\[/g, '|[')
|
||||
.replace(/]/g, '|]')
|
||||
};
|
||||
|
||||
const formatMessage = function () {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
|
||||
for (let i = args.length - 1; i > 0; i--) {
|
||||
args[i] = escapeMessage(args[i])
|
||||
}
|
||||
|
||||
return util.format.apply(null, args) + '\n'
|
||||
};
|
||||
const resolve = require('path').resolve;
|
||||
|
||||
/**
|
||||
* From karma
|
||||
* The MIT License
|
||||
* Copyright (C) 2011-2019 Google, Inc.
|
||||
*/
|
||||
// This ErrorFormatter is copied from standard karma's,
|
||||
// but without warning in case of failed original location finding
|
||||
function createFormatError(config, emitter) {
|
||||
@@ -94,6 +67,38 @@ function createFormatError(config, emitter) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* From karma-teamcity-reporter.
|
||||
* The MIT License
|
||||
* Copyright (C) 2011-2013 Vojta Jína and contributors
|
||||
*/
|
||||
const escapeMessage = function (message) {
|
||||
if (message === null || message === undefined) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return message.toString()
|
||||
.replace(/\|/g, '||')
|
||||
.replace(/'/g, "|'")
|
||||
.replace(/\n/g, '|n')
|
||||
.replace(/\r/g, '|r')
|
||||
.replace(/\u0085/g, '|x')
|
||||
.replace(/\u2028/g, '|l')
|
||||
.replace(/\u2029/g, '|p')
|
||||
.replace(/\[/g, '|[')
|
||||
.replace(/]/g, '|]')
|
||||
};
|
||||
|
||||
const formatMessage = function () {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
|
||||
for (let i = args.length - 1; i > 0; i--) {
|
||||
args[i] = escapeMessage(args[i])
|
||||
}
|
||||
|
||||
return util.format.apply(null, args) + '\n'
|
||||
};
|
||||
|
||||
// This reporter extends karma-teamcity-reporter
|
||||
// It is necessary, because karma-teamcity-reporter can't write browser's log
|
||||
// And additionally it overrides flushLogs, because flushLogs adds redundant spaces after some messages
|
||||
|
||||
Reference in New Issue
Block a user