diff options
-rw-r--r-- | lib/ast.js | 2 | ||||
-rw-r--r-- | lib/output.js | 6 | ||||
-rw-r--r-- | test/mocha/sourcemaps.js | 13 |
3 files changed, 19 insertions, 2 deletions
@@ -1692,7 +1692,7 @@ var AST_ObjectMethod = DEFNODE("ObjectMethod", null, { _validate: function() { 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 (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); diff --git a/lib/output.js b/lib/output.js index c82d2d84..4f530038 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1935,7 +1935,11 @@ function OutputStream(options) { 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); }); })(); diff --git a/test/mocha/sourcemaps.js b/test/mocha/sourcemaps.js index 59642068..32017565 100644 --- a/test/mocha/sourcemaps.js +++ b/test/mocha/sourcemaps.js @@ -101,6 +101,19 @@ describe("sourcemaps", function() { var map = JSON.parse(result.map); 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() { var result = UglifyJS.minify([ "var obj = {};", |