remove all /*@__PURE__*/ on output

This commit is contained in:
alexlamsl 2017-12-24 05:23:18 +08:00
parent 5713261fbf
commit d4e0eb6917
3 changed files with 6 additions and 7 deletions

View File

@ -3148,7 +3148,6 @@ merge(Compressor.prototype, {
}
if (this.pure) {
compressor.warn("Dropping __PURE__ call [{file}:{line},{col}]", this.start);
this.pure.value = this.pure.value.replace(/[@#]__PURE__/g, ' ');
}
var args = trim(this.args, compressor, first_in_statement);
return args && make_sequence(this, args);

View File

@ -510,11 +510,11 @@ function OutputStream(options) {
}
}
if (/comment[134]/.test(c.type)) {
print("//" + c.value + "\n");
print("//" + c.value.replace(/[@#]__PURE__/g, ' ') + "\n");
indent();
last_nlb = true;
} else if (c.type == "comment2") {
print("/*" + c.value + "*/");
print("/*" + c.value.replace(/[@#]__PURE__/g, ' ') + "*/");
last_nlb = false;
}
});
@ -550,10 +550,10 @@ function OutputStream(options) {
space();
}
if (/comment[134]/.test(c.type)) {
print("//" + c.value);
print("//" + c.value.replace(/[@#]__PURE__/g, ' '));
need_newline_indented = true;
} else if (c.type == "comment2") {
print("/*" + c.value + "*/");
print("/*" + c.value.replace(/[@#]__PURE__/g, ' ') + "*/");
need_space = true;
}
});

View File

@ -247,7 +247,7 @@ describe("minify", function() {
var code = result.code;
assert.strictEqual(code, "// comment1 comment2\nbar();");
});
it("should not drop #__PURE__ hint if function is retained", function() {
it("should drop #__PURE__ hint if function is retained", function() {
var result = Uglify.minify("var a = /*#__PURE__*/(function(){ foo(); })();", {
output: {
comments: "all",
@ -255,7 +255,7 @@ describe("minify", function() {
}
});
var code = result.code;
assert.strictEqual(code, "var a=/*#__PURE__*/function(){foo()}();");
assert.strictEqual(code, "var a=/* */function(){foo()}();");
})
});