Skip to content

Commit

Permalink
workaround Safari quirks (#5033)
Browse files Browse the repository at this point in the history
closes #5032
  • Loading branch information
alexlamsl committed Jun 24, 2021
1 parent 7cbcd11 commit 82772cc
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function Compressor(options, false_by_default) {
unsafe_undefined: false,
unused : !false_by_default,
varify : !false_by_default,
webkit : false,
yields : !false_by_default,
}, true);
var evaluate = this.options["evaluate"];
Expand Down Expand Up @@ -5857,6 +5858,7 @@ merge(Compressor.prototype, {
if (head_refs.start.block !== tail_refs.start.block
|| !mergeable(head_refs, tail_refs)
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|| compressor.option("webkit") && is_funarg(def) !== is_funarg(tail.definition)
|| !all(tail_refs, function(sym) {
return sym.scope.find_variable(def.name) === def;
})) {
Expand Down
2 changes: 1 addition & 1 deletion lib/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function minify(files, options) {
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle" ]);
if (options.v8) set_shorthand("v8", options, [ "mangle", "output" ]);
if (options.webkit) set_shorthand("webkit", options, [ "mangle", "output" ]);
if (options.webkit) set_shorthand("webkit", options, [ "compress", "mangle", "output" ]);
var quoted_props;
if (options.mangle) {
options.mangle = defaults(options.mangle, {
Expand Down
74 changes: 74 additions & 0 deletions test/compress/awaits.js
Original file line number Diff line number Diff line change
Expand Up @@ -1915,3 +1915,77 @@ issue_5023_2: {
expect_stdout: "PASS"
node_version: ">=8"
}

issue_5032_normal: {
options = {
merge_vars: true,
webkit: false,
}
input: {
function log(value) {
console.log(value);
return value;
}
async function f(a) {
var b = log(a), c = b;
log(b);
log(c);
}
f("PASS");
}
expect: {
function log(value) {
console.log(value);
return value;
}
async function f(c) {
var b = log(c), c = b;
log(b);
log(c);
}
f("PASS");
}
expect_stdout: [
"PASS",
"PASS",
"PASS",
]
node_version: ">=8"
}

issue_5032_webkit: {
options = {
merge_vars: true,
webkit: true,
}
input: {
function log(value) {
console.log(value);
return value;
}
async function f(a) {
var b = log(a), c = b;
log(b);
log(c);
}
f("PASS");
}
expect: {
function log(value) {
console.log(value);
return value;
}
async function f(a) {
var b = log(a), c = b;
log(b);
log(c);
}
f("PASS");
}
expect_stdout: [
"PASS",
"PASS",
"PASS",
]
node_version: ">=8"
}
74 changes: 74 additions & 0 deletions test/compress/yields.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,3 +1142,77 @@ issue_5019_2: {
]
node_version: ">=4"
}

issue_5032_normal: {
options = {
merge_vars: true,
webkit: false,
}
input: {
function log(value) {
console.log(value);
return value;
}
function *f(a) {
var b = log(a), c = b;
log(b);
log(c);
}
f("PASS").next();
}
expect: {
function log(value) {
console.log(value);
return value;
}
function *f(c) {
var b = log(c), c = b;
log(b);
log(c);
}
f("PASS").next();
}
expect_stdout: [
"PASS",
"PASS",
"PASS",
]
node_version: ">=4"
}

issue_5032_webkit: {
options = {
merge_vars: true,
webkit: true,
}
input: {
function log(value) {
console.log(value);
return value;
}
function *f(a) {
var b = log(a), c = b;
log(b);
log(c);
}
f("PASS").next();
}
expect: {
function log(value) {
console.log(value);
return value;
}
function *f(a) {
var b = log(a), c = b;
log(b);
log(c);
}
f("PASS").next();
}
expect_stdout: [
"PASS",
"PASS",
"PASS",
]
node_version: ">=4"
}

0 comments on commit 82772cc

Please sign in to comment.