enhance sourceMap (#4953)
This commit is contained in:
@@ -1692,7 +1692,7 @@ var AST_ObjectMethod = DEFNODE("ObjectMethod", null, {
|
|||||||
_validate: function() {
|
_validate: function() {
|
||||||
if (!(this.value instanceof AST_LambdaExpression)) throw new Error("value must be AST_LambdaExpression");
|
if (!(this.value instanceof AST_LambdaExpression)) throw new Error("value must be AST_LambdaExpression");
|
||||||
if (is_arrow(this.value)) throw new Error("value cannot be AST_Arrow or AST_AsyncArrow");
|
if (is_arrow(this.value)) throw new Error("value cannot be AST_Arrow or AST_AsyncArrow");
|
||||||
if (this.value.name != null) throw new Error("name of class method's lambda must be null");
|
if (this.value.name != null) throw new Error("name of object method's lambda must be null");
|
||||||
},
|
},
|
||||||
}, AST_ObjectKeyVal);
|
}, AST_ObjectKeyVal);
|
||||||
|
|
||||||
|
|||||||
@@ -1935,7 +1935,11 @@ function OutputStream(options) {
|
|||||||
output.add_mapping(this.start);
|
output.add_mapping(this.start);
|
||||||
});
|
});
|
||||||
|
|
||||||
DEFMAP([ AST_DestructuredKeyVal, AST_ObjectProperty ], function(output) {
|
DEFMAP([
|
||||||
|
AST_ClassProperty,
|
||||||
|
AST_DestructuredKeyVal,
|
||||||
|
AST_ObjectProperty,
|
||||||
|
], function(output) {
|
||||||
if (typeof this.key == "string") output.add_mapping(this.start, this.key);
|
if (typeof this.key == "string") output.add_mapping(this.start, this.key);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -101,6 +101,19 @@ describe("sourcemaps", function() {
|
|||||||
var map = JSON.parse(result.map);
|
var map = JSON.parse(result.map);
|
||||||
assert.deepEqual(map.names, []);
|
assert.deepEqual(map.names, []);
|
||||||
});
|
});
|
||||||
|
it("Should mark class properties", function() {
|
||||||
|
var result = UglifyJS.minify([
|
||||||
|
"class A {",
|
||||||
|
" static P = 42",
|
||||||
|
" set #q(v) {}",
|
||||||
|
"}",
|
||||||
|
].join("\n"), {
|
||||||
|
sourceMap: true,
|
||||||
|
});
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, "class A{static P=42;set#q(s){}}");
|
||||||
|
assert.strictEqual(result.map, '{"version":3,"sources":["0"],"names":["A","P","#q","v"],"mappings":"MAAMA,EACFC,SAAW,GACXC,MAAOC"}');
|
||||||
|
});
|
||||||
it("Should mark array/object literals", function() {
|
it("Should mark array/object literals", function() {
|
||||||
var result = UglifyJS.minify([
|
var result = UglifyJS.minify([
|
||||||
"var obj = {};",
|
"var obj = {};",
|
||||||
|
|||||||
Reference in New Issue
Block a user