[Gradle, JS] Add workaround for debugging with webpack 5
^KT-45621 fixed
This commit is contained in:
committed by
TeamCityServer
parent
fef1892219
commit
4107378d2c
+3
@@ -233,6 +233,9 @@ class KotlinKarma(
|
||||
// noinspection JSUnnecessarySemicolon
|
||||
;(function(config) {
|
||||
const webpack = require('webpack');
|
||||
// https://github.com/webpack/webpack/issues/12951
|
||||
const PatchSourceMapSource = require('kotlin-test-js-runner/webpack-5-debug');
|
||||
config.plugins.push(new PatchSourceMapSource())
|
||||
config.plugins.push(new webpack.SourceMapDevToolPlugin({
|
||||
moduleFilenameTemplate: "[absolute-resource-path]"
|
||||
}))
|
||||
|
||||
+1
-1
@@ -442,7 +442,7 @@ data class KotlinWebpackConfig(
|
||||
// noinspection JSUnnecessarySemicolon
|
||||
;(function(config) {
|
||||
const tcErrorPlugin = require('kotlin-test-js-runner/tc-log-error-webpack');
|
||||
config.plugins.push(new tcErrorPlugin(tcErrorPlugin))
|
||||
config.plugins.push(new tcErrorPlugin())
|
||||
config.stats = config.stats || {}
|
||||
Object.assign(config.stats, config.stats, {
|
||||
warnings: false,
|
||||
|
||||
@@ -54,6 +54,7 @@ tasks {
|
||||
"mocha-kotlin-reporter.js",
|
||||
"tc-log-appender.js",
|
||||
"tc-log-error-webpack.js",
|
||||
"webpack-5-debug.js",
|
||||
"package.json",
|
||||
"rollup.config.js",
|
||||
"tsconfig.json",
|
||||
|
||||
@@ -66,6 +66,13 @@ export default [
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './webpack-5-debug.js',
|
||||
output: {
|
||||
file: 'lib/webpack-5-debug.js',
|
||||
format: 'cjs'
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './mocha-kotlin-reporter.js',
|
||||
external: ['path', 'util'],
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
const {SourceMapSource} = require("webpack-sources");
|
||||
const {absolutify} = require("webpack/lib/util/identifier");
|
||||
|
||||
// https://github.com/webpack/webpack/issues/12951
|
||||
class PatchSourceMapSourcePlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.beforeRun.tap("PathcSourceMapSourcePlugin", compiler => {
|
||||
const original = SourceMapSource.prototype._ensureSourceMapObject;
|
||||
|
||||
SourceMapSource.prototype._ensureSourceMapObject = function () {
|
||||
original.call(this)
|
||||
this._sourceMapAsObject.sources = this._sourceMapAsObject
|
||||
.sources
|
||||
.map(source => {
|
||||
if (!source.startsWith("webpack://")) return source
|
||||
|
||||
return absolutify(compiler.options.context, source.slice(10))
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PatchSourceMapSourcePlugin;
|
||||
Reference in New Issue
Block a user