feat(es/minifier): Enable dead_code by default (#4309)

This commit is contained in:
Donny/강동윤 2022-04-12 12:40:10 +09:00 committed by GitHub
parent e133071c41
commit 74a5087989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 35 deletions

View File

@ -57,14 +57,14 @@ var Formatting;
var indentationInfo = null; var indentationInfo = null;
switch(token.Token){ switch(token.Token){
case AuthorTokenKind.atkLCurly: case AuthorTokenKind.atkLCurly:
return indentationInfo = this.GetSpecialCaseIndentationForLCurly(node); return this.GetSpecialCaseIndentationForLCurly(node);
case AuthorTokenKind.atkElse: case AuthorTokenKind.atkElse:
case AuthorTokenKind.atkRBrack: case AuthorTokenKind.atkRBrack:
return indentationInfo = node.GetNodeStartLineIndentation(this); return node.GetNodeStartLineIndentation(this);
case AuthorTokenKind.atkRCurly: case AuthorTokenKind.atkRCurly:
return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkBlock && node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneBody && (node = node.Parent), indentationInfo = node.GetNodeStartLineIndentation(this); return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkBlock && node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneBody && (node = node.Parent), indentationInfo = node.GetNodeStartLineIndentation(this);
case AuthorTokenKind.atkWhile: case AuthorTokenKind.atkWhile:
if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkDoWhile) return indentationInfo = node.GetNodeStartLineIndentation(this); if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkDoWhile) return node.GetNodeStartLineIndentation(this);
return null; return null;
case AuthorTokenKind.atkSColon: case AuthorTokenKind.atkSColon:
return this.GetSpecialCaseIndentationForSemicolon(token, node); return this.GetSpecialCaseIndentationForSemicolon(token, node);

View File

@ -47,14 +47,14 @@ import * as swcHelpers from "@swc/helpers";
var indentationInfo = null; var indentationInfo = null;
switch(token.Token){ switch(token.Token){
case AuthorTokenKind.atkLCurly: case AuthorTokenKind.atkLCurly:
return indentationInfo = this.GetSpecialCaseIndentationForLCurly(node); return this.GetSpecialCaseIndentationForLCurly(node);
case AuthorTokenKind.atkElse: case AuthorTokenKind.atkElse:
case AuthorTokenKind.atkRBrack: case AuthorTokenKind.atkRBrack:
return indentationInfo = node.GetNodeStartLineIndentation(this); return node.GetNodeStartLineIndentation(this);
case AuthorTokenKind.atkRCurly: case AuthorTokenKind.atkRCurly:
return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkBlock && node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneBody && (node = node.Parent), indentationInfo = node.GetNodeStartLineIndentation(this); return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkBlock && node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneBody && (node = node.Parent), indentationInfo = node.GetNodeStartLineIndentation(this);
case AuthorTokenKind.atkWhile: case AuthorTokenKind.atkWhile:
if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkDoWhile) return indentationInfo = node.GetNodeStartLineIndentation(this); if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkDoWhile) return node.GetNodeStartLineIndentation(this);
return null; return null;
case AuthorTokenKind.atkSColon: case AuthorTokenKind.atkSColon:
return this.GetSpecialCaseIndentationForSemicolon(token, node); return this.GetSpecialCaseIndentationForSemicolon(token, node);

View File

@ -128,7 +128,7 @@ pub struct CompressOptions {
#[serde(alias = "conditionals")] #[serde(alias = "conditionals")]
pub conditionals: bool, pub conditionals: bool,
#[serde(default)] #[serde(default = "true_by_default")]
#[serde(alias = "dead_code")] #[serde(alias = "dead_code")]
pub dead_code: bool, pub dead_code: bool,

View File

@ -314,8 +314,7 @@ impl TerserCompressorOptions {
// TODO: Use self.defaults // TODO: Use self.defaults
computed_props: self.computed_props.unwrap_or(false), computed_props: self.computed_props.unwrap_or(false),
conditionals: self.conditionals.unwrap_or(self.defaults), conditionals: self.conditionals.unwrap_or(self.defaults),
// TODO: Use self.defaults dead_code: self.dead_code.unwrap_or(self.defaults),
dead_code: self.dead_code.unwrap_or(false),
// TODO: Use self.defaults // TODO: Use self.defaults
directives: self.directives.unwrap_or(false), directives: self.directives.unwrap_or(false),
drop_console: self.drop_console, drop_console: self.drop_console,

View File

@ -6081,7 +6081,7 @@
divide(data, 1 << j), multiply(data, 1, 1), divide(data, 2), result = dataToString(data); divide(data, 1 << j), multiply(data, 1, 1), divide(data, 2), result = dataToString(data);
} else multiply(data, 0, z), multiply(data, 1 << -e, 0), result = dataToString(data) + repeat.call('0', fractDigits); } else multiply(data, 0, z), multiply(data, 1 << -e, 0), result = dataToString(data) + repeat.call('0', fractDigits);
} }
return result = fractDigits > 0 ? sign + ((k = result.length) <= fractDigits ? '0.' + repeat.call('0', fractDigits - k) + result : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits)) : sign + result; return fractDigits > 0 ? sign + ((k = result.length) <= fractDigits ? '0.' + repeat.call('0', fractDigits - k) + result : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits)) : sign + result;
} }
}); });
}, },
@ -12436,23 +12436,20 @@
} }
} }
if (0 == (7 & b9)) { if (0 == (7 & b9)) {
a: { if (h = "mouseover" === a12 || "pointerover" === a12, k = "mouseout" === a12 || "pointerout" === a12, !(h && 0 == (16 & b9) && (x = c5.relatedTarget || c5.fromElement) && (wc(x) || x[ff])) && (k || h) && (h = e.window === e ? e : (h = e.ownerDocument) ? h.defaultView || h.parentWindow : window, k ? (x = c5.relatedTarget || c5.toElement, k = d, null !== (x = x ? wc(x) : null) && (z = Zb(x), x !== z || 5 !== x.tag && 6 !== x.tag) && (x = null)) : (k = null, x = d), k !== x)) {
if (h = "mouseover" === a12 || "pointerover" === a12, k = "mouseout" === a12 || "pointerout" === a12, h && 0 == (16 & b9) && (x = c5.relatedTarget || c5.fromElement) && (wc(x) || x[ff])) break a; if (w = Bd, v = "onMouseLeave", u = "onMouseEnter", t = "mouse", ("pointerout" === a12 || "pointerover" === a12) && (w = Td, v = "onPointerLeave", u = "onPointerEnter", t = "pointer"), z = null == k ? h : ue(k), q = null == x ? h : ue(x), (h = new w(v, t + "leave", k, c5, e)).target = z, h.relatedTarget = q, v = null, wc(e) === d && ((w = new w(u, t + "enter", x, c5, e)).target = q, w.relatedTarget = z, v = w), z = v, k && x) b: {
if ((k || h) && (h = e.window === e ? e : (h = e.ownerDocument) ? h.defaultView || h.parentWindow : window, k ? (x = c5.relatedTarget || c5.toElement, k = d, null !== (x = x ? wc(x) : null) && (z = Zb(x), x !== z || 5 !== x.tag && 6 !== x.tag) && (x = null)) : (k = null, x = d), k !== x)) { for(w = k, u = x, t = 0, q = w; q; q = gf(q))t++;
if (w = Bd, v = "onMouseLeave", u = "onMouseEnter", t = "mouse", ("pointerout" === a12 || "pointerover" === a12) && (w = Td, v = "onPointerLeave", u = "onPointerEnter", t = "pointer"), z = null == k ? h : ue(k), q = null == x ? h : ue(x), (h = new w(v, t + "leave", k, c5, e)).target = z, h.relatedTarget = q, v = null, wc(e) === d && ((w = new w(u, t + "enter", x, c5, e)).target = q, w.relatedTarget = z, v = w), z = v, k && x) b: { for(q = 0, v = u; v; v = gf(v))q++;
for(w = k, u = x, t = 0, q = w; q; q = gf(q))t++; for(; 0 < t - q;)w = gf(w), t--;
for(q = 0, v = u; v; v = gf(v))q++; for(; 0 < q - t;)u = gf(u), q--;
for(; 0 < t - q;)w = gf(w), t--; for(; t--;){
for(; 0 < q - t;)u = gf(u), q--; if (w === u || null !== u && w === u.alternate) break b;
for(; t--;){ w = gf(w), u = gf(u);
if (w === u || null !== u && w === u.alternate) break b;
w = gf(w), u = gf(u);
}
w = null;
} }
else w = null; w = null;
null !== k && hf(g, h, k, w, !1), null !== x && null !== z && hf(g, z, x, w, !0);
} }
else w = null;
null !== k && hf(g, h, k, w, !1), null !== x && null !== z && hf(g, z, x, w, !0);
} }
a: { a: {
if ("select" === (k = (h = d ? ue(d) : window).nodeName && h.nodeName.toLowerCase()) || "input" === k && "file" === h.type) var Q, J = ve; if ("select" === (k = (h = d ? ue(d) : window).nodeName && h.nodeName.toLowerCase()) || "input" === k && "file" === h.type) var Q, J = ve;

View File

@ -6521,10 +6521,10 @@
}, getKnownPartCount = function(_ref) { }, getKnownPartCount = function(_ref) {
var preloadSegment = _ref.preloadSegment; var preloadSegment = _ref.preloadSegment;
if (preloadSegment) { if (preloadSegment) {
var parts = preloadSegment.parts, partCount = (preloadSegment.preloadHints || []).reduce(function(count, hint) { var parts = preloadSegment.parts;
return (preloadSegment.preloadHints || []).reduce(function(count, hint) {
return count + ('PART' === hint.type ? 1 : 0); return count + ('PART' === hint.type ? 1 : 0);
}, 0); }, 0) + (parts && parts.length ? parts.length : 0);
return partCount += parts && parts.length ? parts.length : 0;
} }
}, liveEdgeDelay = function(master, media) { }, liveEdgeDelay = function(master, media) {
if (media.endList) return 0; if (media.endList) return 0;

File diff suppressed because one or more lines are too long

View File

@ -3321,8 +3321,8 @@
return 12 > date.getHours() ? formats.AMPMS[0] : formats.AMPMS[1]; return 12 > date.getHours() ? formats.AMPMS[0] : formats.AMPMS[1];
}, },
Z: function(date) { Z: function(date) {
var zone = -1 * date.getTimezoneOffset(), paddedZone = zone >= 0 ? "+" : ""; var zone = -1 * date.getTimezoneOffset();
return paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) + padNumber(Math.abs(zone % 60), 2); return (zone >= 0 ? "+" : "") + (padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) + padNumber(Math.abs(zone % 60), 2));
} }
}, DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/, NUMBER_STRING = /^\-?\d+$/; }, DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/, NUMBER_STRING = /^\-?\d+$/;
function dateFilter($locale) { function dateFilter($locale) {

View File

@ -1494,10 +1494,7 @@ Event.Keys = {}, Event.Keys = new Hash(Event.Keys), function() {
return; return;
} }
} }
getByTag: { if ((children = node.getElementsByTagName(tag)) && children.length) for(this.brokenStarGEBTN || (tag = null), i = 0; item = children[i++];)this.push(item, tag, id, classes, attributes, pseudos);
if (!((children = node.getElementsByTagName(tag)) && children.length)) break getByTag;
for(this.brokenStarGEBTN || (tag = null), i = 0; item = children[i++];)this.push(item, tag, id, classes, attributes, pseudos);
}
}, },
'>': function(node, tag, id, classes, attributes, pseudos) { '>': function(node, tag, id, classes, attributes, pseudos) {
if (node = node.firstChild) do 1 == node.nodeType && this.push(node, tag, id, classes, attributes, pseudos); if (node = node.firstChild) do 1 == node.nodeType && this.push(node, tag, id, classes, attributes, pseudos);