prevent input source map mutation (#3781)

fixes #3780
This commit is contained in:
Alex Lam S.L
2020-04-15 10:25:58 +01:00
committed by GitHub
parent c4d28e3b2a
commit 6e9afdc94f
2 changed files with 16 additions and 6 deletions

View File

@@ -103,12 +103,16 @@ function SourceMap(options) {
if (options.orig) Object.keys(options.orig).forEach(function(name) {
var map = options.orig[name];
var indices = [ 0, 0, 1, 0, 0 ];
map.mappings = map.mappings.split(/;/).map(function(line) {
indices[0] = 0;
return line.split(/,/).map(function(segment) {
return indices.slice(0, vlq_decode(indices, segment));
});
});
options.orig[name] = {
names: map.names,
mappings: map.mappings.split(/;/).map(function(line) {
indices[0] = 0;
return line.split(/,/).map(function(segment) {
return indices.slice(0, vlq_decode(indices, segment));
});
}),
sources: map.sources,
};
if (!sources_content || !map.sourcesContent) return;
for (var i = 0; i < map.sources.length; i++) {
var content = map.sourcesContent[i];