[Gradle, JS] Add workaround for debugging with webpack 5

^KT-45621 fixed
This commit is contained in:
Ilya Goncharov
2021-03-23 15:00:31 +03:00
committed by TeamCityServer
parent fef1892219
commit 4107378d2c
5 changed files with 38 additions and 1 deletions
@@ -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;