[Pkg-javascript-commits] [uglifyjs] 213/491: improve source mapping (#2312)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:37 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 182a47bfb1d49a99a561253edc05e70a6dc5b8e8
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Sep 15 12:46:48 2017 +0800

    improve source mapping (#2312)
    
    fixes #2310
---
 lib/output.js                  |  2 +-
 test/input/issue-2310/input.js | 10 ++++++++++
 test/mocha/cli.js              | 19 +++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lib/output.js b/lib/output.js
index 6f7b18d..315bfaf 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -1109,7 +1109,7 @@ function OutputStream(options) {
         self.expression.print(output);
         if (self instanceof AST_New && !need_constructor_parens(self, output))
             return;
-        if (self.expression instanceof AST_Lambda) {
+        if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
             output.add_mapping(self.start);
         }
         output.with_parens(function(){
diff --git a/test/input/issue-2310/input.js b/test/input/issue-2310/input.js
new file mode 100644
index 0000000..ea7c1f3
--- /dev/null
+++ b/test/input/issue-2310/input.js
@@ -0,0 +1,10 @@
+function foo() {
+    return function() {
+        console.log("PASS");
+    };
+}
+
+(function() {
+    var f = foo();
+    f();
+})();
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 1d847dc..85b2e8c 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -573,6 +573,25 @@ describe("bin/uglifyjs", function () {
             return JSON.stringify(map).replace(/"/g, '\\"');
         }
     });
+    it("Should include function calls in source map", function(done) {
+        var command = [
+            uglifyjscmd,
+            "test/input/issue-2310/input.js",
+            "-c",
+            "--source-map", "url=inline",
+        ].join(" ");
+
+        exec(command, function(err, stdout, stderr) {
+            if (err) throw err;
+
+            assert.strictEqual(stdout, [
+                'function foo(){return function(){console.log("PASS")}}foo()();',
+                "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvaW5wdXQvaXNzdWUtMjMxMC9pbnB1dC5qcyJdLCJuYW1lcyI6WyJmb28iLCJjb25zb2xlIiwibG9nIiwiZiJdLCJtYXBwaW5ncyI6IkFBQUEsU0FBU0EsTUFDTCxPQUFPLFdBQ0hDLFFBQVFDLElBQUksU0FLUkYsS0FDUkcifQ==",
+                ""
+            ].join("\n"));
+            done();
+        });
+    });
     it("Should dump AST as JSON", function(done) {
         var command = uglifyjscmd + " test/input/global_defs/simple.js -mco ast";
         exec(command, function (err, stdout) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list