improve usability of includeSources (#3057)

Exclude source contents from input source map if `includeSources=false`

fixes #3041
This commit is contained in:
Alex Lam S.L
2018-04-06 13:32:26 +08:00
committed by GitHub
parent 44116c6d2b
commit 0b62a28b47
4 changed files with 84 additions and 48 deletions

View File

@@ -70,6 +70,7 @@ describe("sourcemaps", function() {
compress: { toplevel: true },
sourceMap: {
content: "inline",
includeSources: true,
url: "inline"
}
}).code + "\n";
@@ -109,6 +110,29 @@ describe("sourcemaps", function() {
assert.ok(err instanceof Error);
assert.strictEqual(err.stack.split(/\n/)[0], "Error: inline source map only works with singular input");
});
it("Should drop source contents for includeSources=false", function() {
var result = Uglify.minify(read("./test/input/issue-520/input.js"), {
compress: false,
mangle: false,
sourceMap: {
content: "inline",
includeSources: true,
},
});
if (result.error) throw result.error;
var map = JSON.parse(result.map);
assert.strictEqual(map.sourcesContent.length, 1);
result = Uglify.minify(result.code, {
compress: false,
mangle: false,
sourceMap: {
content: result.map,
},
});
if (result.error) throw result.error;
map = JSON.parse(result.map);
assert.ok(!("sourcesContent" in map));
});
});
describe("sourceMapInline", function() {