feat(es/minifier): Drop pure new calls (#4478)

This commit is contained in:
Donny/강동윤 2022-04-29 16:22:13 +09:00 committed by GitHub
parent 588adf0913
commit 918c9c8a21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 49 additions and 99 deletions

View File

@ -5,30 +5,7 @@ export var AppType;
export var AppStyle;
!function(AppStyle) {
AppStyle[AppStyle.Tree = 0] = "Tree", AppStyle[AppStyle.TreeEntity = 1] = "TreeEntity", AppStyle[AppStyle.Standard = 2] = "Standard", AppStyle[AppStyle.MiniApp = 3] = "MiniApp", AppStyle[AppStyle.PivotTable = 4] = "PivotTable";
}(AppStyle || (AppStyle = {})), new Map([
[
AppType.Standard,
[
AppStyle.Standard,
AppStyle.MiniApp
]
],
[
AppType.Relationship,
[
AppStyle.Standard,
AppStyle.Tree,
AppStyle.TreeEntity
]
],
[
AppType.AdvancedList,
[
AppStyle.Standard,
AppStyle.MiniApp
]
]
]), foo({
}(AppStyle || (AppStyle = {})), AppType.Standard, AppStyle.Standard, AppStyle.MiniApp, AppType.Relationship, AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity, AppType.AdvancedList, AppStyle.Standard, AppStyle.MiniApp, foo({
x: !0
}, {
x: !1

View File

@ -5,30 +5,7 @@ export var AppType;
export var AppStyle;
!function(AppStyle) {
AppStyle[AppStyle.Tree = 0] = "Tree", AppStyle[AppStyle.TreeEntity = 1] = "TreeEntity", AppStyle[AppStyle.Standard = 2] = "Standard", AppStyle[AppStyle.MiniApp = 3] = "MiniApp", AppStyle[AppStyle.PivotTable = 4] = "PivotTable";
}(AppStyle || (AppStyle = {})), new Map([
[
AppType.Standard,
[
AppStyle.Standard,
AppStyle.MiniApp
]
],
[
AppType.Relationship,
[
AppStyle.Standard,
AppStyle.Tree,
AppStyle.TreeEntity
]
],
[
AppType.AdvancedList,
[
AppStyle.Standard,
AppStyle.MiniApp
]
]
]), foo({
}(AppStyle || (AppStyle = {})), AppType.Standard, AppStyle.Standard, AppStyle.MiniApp, AppType.Relationship, AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity, AppType.AdvancedList, AppStyle.Standard, AppStyle.MiniApp, foo({
x: !0
}, {
x: !1

View File

@ -1 +0,0 @@
new Array(1), new Array(), new Array(1), new Array();

View File

@ -1 +0,0 @@
new Array(1), new Array(), new Array(1), new Array();

View File

@ -1,2 +1,2 @@
var NUMBER;
NUMBER.toString(), new Object, NUMBER.toString(), new Object;
NUMBER.toString(), NUMBER.toString();

View File

@ -1,2 +1,2 @@
var NUMBER;
NUMBER.toString(), new Object, NUMBER.toString(), new Object;
NUMBER.toString(), NUMBER.toString();

View File

@ -1,2 +1,2 @@
var NUMBER, STRING;
++NUMBER, STRING.charAt(0), new Object(), ++NUMBER, STRING.charAt(0), new Object();
++NUMBER, STRING.charAt(0), ++NUMBER, STRING.charAt(0);

View File

@ -1,2 +1,2 @@
var NUMBER, STRING;
++NUMBER, STRING.charAt(0), new Object(), ++NUMBER, STRING.charAt(0), new Object();
++NUMBER, STRING.charAt(0), ++NUMBER, STRING.charAt(0);

View File

@ -6,5 +6,5 @@ class C {
}, M1.F2 = function(x) {
return x.toString();
};
}(M || (M = {})), new Object(), new C(), new C(), new class {
}(M || (M = {})), new C(), new C(), new class {
}(), new C(), new M.A();

View File

@ -14,4 +14,4 @@ var M, C = function() {
M1.A = A, M1.F2 = function(x) {
return x.toString();
};
}(M || (M = {})), new Object(), new C(), new C(), new D(), new C(), new M.A();
}(M || (M = {})), new C(), new C(), new D(), new C(), new M.A();

View File

@ -6,5 +6,5 @@ class C {
}, M1.F2 = function(x) {
return x.toString();
};
}(M || (M = {})), new Object(), new C(), new C(), new class {
}(M || (M = {})), new C(), new C(), new class {
}(), new M.A(), M.F2;

View File

@ -14,4 +14,4 @@ var M, C = function() {
M1.A = A, M1.F2 = function(x) {
return x.toString();
};
}(M || (M = {})), new Object(), new C(), new C(), new D(), new M.A(), M.F2;
}(M || (M = {})), new C(), new C(), new D(), new M.A(), M.F2;

View File

@ -25,6 +25,6 @@ for(;;);
for(;;);
for(new C(), new C2(), new D();;);
for(new D();;);
for(new Array();;);
for(;;);
for(;;);
M.A;

View File

@ -38,6 +38,6 @@ for(;;);
for(;;);
for(new C(), new C2(), new D();;);
for(new D();;);
for(new Array();;);
for(;;);
for(;;);
M.A;

View File

@ -19,4 +19,4 @@ for(;;);
for(;;);
for(;;);
for(;;);
for(new Array();;);
for(;;);

View File

@ -19,4 +19,4 @@ for(;;);
for(;;);
for(;;);
for(;;);
for(new Array();;);
for(;;);

View File

@ -10,7 +10,7 @@ for(var M;;);
for(;;);
for(;;);
for(;;);
for(new Object();;);
for(;;);
for(;;);
for(;;);
for(;;);

View File

@ -18,7 +18,7 @@ for(!function(M1) {
for(;;);
for(;;);
for(;;);
for(new Object();;);
for(;;);
for(;;);
for(;;);
for(;;);

View File

@ -10,4 +10,4 @@ class D {
}, M1.F2 = function(x) {
return x.toString();
};
}(M || (M = {})), new C(), new D(), new C(), new C2(), new C(), new C2(), new D(), new D(), new Array(), M.A;
}(M || (M = {})), new C(), new D(), new C(), new C2(), new C(), new C2(), new D(), new D(), M.A;

View File

@ -22,4 +22,4 @@ var M, C = function() {
M1.A = A, M1.F2 = function(x) {
return x.toString();
};
}(M || (M = {})), new C(), new D(), new C(), new C2(), new C(), new C2(), new D(), new D(), new Array(), M.A;
}(M || (M = {})), new C(), new D(), new C(), new C2(), new C(), new C2(), new D(), new D(), M.A;

View File

@ -5,4 +5,4 @@ function f() {}
}(E || (E = {})), E.A, (f || (f = {})).bar = 1;
class c {
}
(c || (c = {})).bar = 1, new Object();
(c || (c = {})).bar = 1;

View File

@ -14,4 +14,4 @@ var c = function() {
"use strict";
swcHelpers.classCallCheck(this, c);
};
(c || (c = {})).bar = 1, new Object();
(c || (c = {})).bar = 1;

View File

@ -5,5 +5,4 @@ var M;
}
M1.fn = fn;
}(M || (M = {})), new class {
}(), new Object(), (x)=>''
;
}();

View File

@ -14,4 +14,4 @@ var M, C = function() {
}
return D;
}(C);
new C(), new Object();
new C();

View File

@ -806,6 +806,29 @@ impl Pure<'_> {
_ => {}
}
if self.options.side_effects {
if let Expr::New(NewExpr { callee, args, .. }) = e {
if let Expr::Ident(i) = &**callee {
match &*i.sym {
"Map" | "Set" | "Array" | "Object" | "Boolean" | "Number" => {
if i.span.ctxt.outer() == self.marks.unresolved_mark {
report_change!("Dropping a pure new expression");
self.changed = true;
*e = self
.make_ignored_expr(
args.iter_mut().flatten().map(|arg| arg.expr.take()),
)
.unwrap_or(Expr::Invalid(Invalid { span: DUMMY_SP }));
return;
}
}
_ => {}
}
}
}
}
// Remove pure member expressions.
if let Expr::Member(MemberExpr { obj, prop, .. }) = e {
if let Expr::Ident(obj) = &**obj {

View File

@ -1991,9 +1991,7 @@
for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]);
return target;
}
var loadedImageURLs = new Set();
new Map();
var emptyDataURL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', loaders = new Map([
var loadedImageURLs = new Set(), emptyDataURL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', loaders = new Map([
[
'default',
function(param) {

View File

@ -312,9 +312,7 @@
for(i = 0; i < sourceKeys.length; i++)key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]);
return target;
}
var loadedImageURLs = new Set();
new Map();
var emptyDataURL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', loaders = new Map([
var loadedImageURLs = new Set(), emptyDataURL = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', loaders = new Map([
[
'default',
function(param) {

View File

@ -602,15 +602,7 @@
}
var didWarnAboutDeprecatedCreateFactory = !1;
try {
var frozenObject = Object.freeze({});
new Map([
[
frozenObject,
null
]
]), new Set([
frozenObject
]);
Object.freeze({});
} catch (e) {}
exports.Children = {
map: mapChildren,

View File

@ -8932,15 +8932,7 @@
}
hasBadMapPolyfill = !1;
try {
var nonExtensibleObject = Object.preventExtensions({});
new Map([
[
nonExtensibleObject,
null
]
]), new Set([
nonExtensibleObject
]);
Object.preventExtensions({});
} catch (e) {
hasBadMapPolyfill = !0;
}