Files
kotlin-fork/libraries/tools/kotlin-test-js-runner/webpack-5-debug.js
T
2023-01-25 16:06:29 +00:00

26 lines
918 B
JavaScript

"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("PatchSourceMapSourcePlugin", 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;