From 918c9c8a21c248617aef4474380c94f9f98df1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 29 Apr 2022 16:22:13 +0900 Subject: [PATCH] feat(es/minifier): Drop pure `new` calls (#4478) --- ...arrayLiteralInference_es2015.2.minified.js | 25 +------------------ .../arrayLiteralInference_es5.2.minified.js | 25 +------------------ .../arrayLiteral_es2015.2.minified.js | 1 - .../arrayLiteral_es5.2.minified.js | 1 - ...condOperandStringType_es2015.2.minified.js | 2 +- ...hSecondOperandStringType_es5.2.minified.js | 2 +- ...torsMultipleOperators_es2015.2.minified.js | 2 +- ...eratorsMultipleOperators_es5.2.minified.js | 2 +- ...otationAndInitializer_es2015.2.minified.js | 2 +- ...AnnotationAndInitializer_es5.2.minified.js | 2 +- ...ryTypeWithInitializer_es2015.2.minified.js | 2 +- ...everyTypeWithInitializer_es5.2.minified.js | 2 +- ...tsMultipleInvalidDecl_es2015.2.minified.js | 2 +- ...mentsMultipleInvalidDecl_es5.2.minified.js | 2 +- ...entsMultipleValidDecl_es2015.2.minified.js | 2 +- ...tementsMultipleValidDecl_es5.2.minified.js | 2 +- .../forStatements_es2015.2.minified.js | 2 +- .../forStatements_es5.2.minified.js | 2 +- ...eVariableDeclarations_es2015.2.minified.js | 2 +- ...ipleVariableDeclarations_es5.2.minified.js | 2 +- ...verythingButUndefined_es2015.2.minified.js | 2 +- ...OfEverythingButUndefined_es5.2.minified.js | 2 +- ...parserObjectCreation1_es2015.2.minified.js | 1 - .../parserObjectCreation1_es5.2.minified.js | 1 - .../switchStatements_es2015.2.minified.js | 3 +-- .../switchStatements_es5.2.minified.js | 2 +- ...eVariableDeclarations_es2015.2.minified.js | 1 - ...ipleVariableDeclarations_es5.2.minified.js | 1 - .../src/compress/pure/misc.rs | 23 +++++++++++++++++ .../fixture/issues/firebase-core/1/output.js | 4 +-- .../fixture/issues/react-countup/1/output.js | 4 +-- .../tests/projects/output/react-17.0.1.js | 10 +------- .../tests/projects/output/react-dom-17.0.2.js | 10 +------- 33 files changed, 49 insertions(+), 99 deletions(-) diff --git a/crates/swc/tests/tsc-references/arrayLiteralInference_es2015.2.minified.js b/crates/swc/tests/tsc-references/arrayLiteralInference_es2015.2.minified.js index 8ab6d878204..f39e8e87cd2 100644 --- a/crates/swc/tests/tsc-references/arrayLiteralInference_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/arrayLiteralInference_es2015.2.minified.js @@ -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 diff --git a/crates/swc/tests/tsc-references/arrayLiteralInference_es5.2.minified.js b/crates/swc/tests/tsc-references/arrayLiteralInference_es5.2.minified.js index 8ab6d878204..f39e8e87cd2 100644 --- a/crates/swc/tests/tsc-references/arrayLiteralInference_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/arrayLiteralInference_es5.2.minified.js @@ -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 diff --git a/crates/swc/tests/tsc-references/arrayLiteral_es2015.2.minified.js b/crates/swc/tests/tsc-references/arrayLiteral_es2015.2.minified.js index 390b0d75e9c..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/arrayLiteral_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/arrayLiteral_es2015.2.minified.js @@ -1 +0,0 @@ -new Array(1), new Array(), new Array(1), new Array(); diff --git a/crates/swc/tests/tsc-references/arrayLiteral_es5.2.minified.js b/crates/swc/tests/tsc-references/arrayLiteral_es5.2.minified.js index 390b0d75e9c..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/arrayLiteral_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/arrayLiteral_es5.2.minified.js @@ -1 +0,0 @@ -new Array(1), new Array(), new Array(1), new Array(); diff --git a/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es2015.2.minified.js b/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es2015.2.minified.js index 795b3a522c8..3667d52ecd4 100644 --- a/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es2015.2.minified.js @@ -1,2 +1,2 @@ var NUMBER; -NUMBER.toString(), new Object, NUMBER.toString(), new Object; +NUMBER.toString(), NUMBER.toString(); diff --git a/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es5.2.minified.js b/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es5.2.minified.js index 795b3a522c8..3667d52ecd4 100644 --- a/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/commaOperatorWithSecondOperandStringType_es5.2.minified.js @@ -1,2 +1,2 @@ var NUMBER; -NUMBER.toString(), new Object, NUMBER.toString(), new Object; +NUMBER.toString(), NUMBER.toString(); diff --git a/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es2015.2.minified.js b/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es2015.2.minified.js index 78bf9751366..65a12fd4b77 100644 --- a/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es2015.2.minified.js @@ -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); diff --git a/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es5.2.minified.js b/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es5.2.minified.js index 78bf9751366..65a12fd4b77 100644 --- a/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/commaOperatorsMultipleOperators_es5.2.minified.js @@ -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); diff --git a/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js b/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js index 4f6301b4bfd..4083acf1b81 100644 --- a/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js @@ -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(); diff --git a/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es5.2.minified.js b/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es5.2.minified.js index 9074c73a157..f51b7ba79bd 100644 --- a/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es5.2.minified.js @@ -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(); diff --git a/crates/swc/tests/tsc-references/everyTypeWithInitializer_es2015.2.minified.js b/crates/swc/tests/tsc-references/everyTypeWithInitializer_es2015.2.minified.js index 851c9f549cb..7f1cfc8bfd8 100644 --- a/crates/swc/tests/tsc-references/everyTypeWithInitializer_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/everyTypeWithInitializer_es2015.2.minified.js @@ -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; diff --git a/crates/swc/tests/tsc-references/everyTypeWithInitializer_es5.2.minified.js b/crates/swc/tests/tsc-references/everyTypeWithInitializer_es5.2.minified.js index 245db94ce82..e0c70b8db5e 100644 --- a/crates/swc/tests/tsc-references/everyTypeWithInitializer_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/everyTypeWithInitializer_es5.2.minified.js @@ -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; diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js index 1671e42ec59..11969d286df 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js @@ -25,6 +25,6 @@ for(;;); for(;;); for(new C(), new C2(), new D();;); for(new D();;); -for(new Array();;); +for(;;); for(;;); M.A; diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js index 833c50086ae..3b5ad6a6e62 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js @@ -38,6 +38,6 @@ for(;;); for(;;); for(new C(), new C2(), new D();;); for(new D();;); -for(new Array();;); +for(;;); for(;;); M.A; diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js index cbaab968b8e..91faec76220 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js @@ -19,4 +19,4 @@ for(;;); for(;;); for(;;); for(;;); -for(new Array();;); +for(;;); diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js index cbaab968b8e..91faec76220 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js @@ -19,4 +19,4 @@ for(;;); for(;;); for(;;); for(;;); -for(new Array();;); +for(;;); diff --git a/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js index 6ee47917002..d6920f7c758 100644 --- a/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js @@ -10,7 +10,7 @@ for(var M;;); for(;;); for(;;); for(;;); -for(new Object();;); +for(;;); for(;;); for(;;); for(;;); diff --git a/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js index 42dcbef14d9..527ed3758fb 100644 --- a/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js @@ -18,7 +18,7 @@ for(!function(M1) { for(;;); for(;;); for(;;); -for(new Object();;); +for(;;); for(;;); for(;;); for(;;); diff --git a/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js b/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js index d495ef9ec2e..ffcd01f7794 100644 --- a/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js @@ -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; diff --git a/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es5.2.minified.js b/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es5.2.minified.js index 2003702da0a..ee1b339057d 100644 --- a/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es5.2.minified.js @@ -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; diff --git a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es2015.2.minified.js b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es2015.2.minified.js index a37c015ff9f..1a98012490d 100644 --- a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es2015.2.minified.js @@ -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; diff --git a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es5.2.minified.js b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es5.2.minified.js index b598d92799d..23aa712f432 100644 --- a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined_es5.2.minified.js @@ -14,4 +14,4 @@ var c = function() { "use strict"; swcHelpers.classCallCheck(this, c); }; -(c || (c = {})).bar = 1, new Object(); +(c || (c = {})).bar = 1; diff --git a/crates/swc/tests/tsc-references/parserObjectCreation1_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserObjectCreation1_es2015.2.minified.js index 88b820ff4a7..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserObjectCreation1_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserObjectCreation1_es2015.2.minified.js @@ -1 +0,0 @@ -new Array(1); diff --git a/crates/swc/tests/tsc-references/parserObjectCreation1_es5.2.minified.js b/crates/swc/tests/tsc-references/parserObjectCreation1_es5.2.minified.js index 88b820ff4a7..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserObjectCreation1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserObjectCreation1_es5.2.minified.js @@ -1 +0,0 @@ -new Array(1); diff --git a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js index 48fafa36907..0db4f1476d3 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js @@ -5,5 +5,4 @@ var M; } M1.fn = fn; }(M || (M = {})), new class { -}(), new Object(), (x)=>'' -; +}(); diff --git a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js index a463698f4be..ea424984d61 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js @@ -14,4 +14,4 @@ var M, C = function() { } return D; }(C); -new C(), new Object(); +new C(); diff --git a/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es2015.2.minified.js b/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es2015.2.minified.js index 6a6c7a8a89f..4ab96f09617 100644 --- a/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es2015.2.minified.js @@ -1,2 +1 @@ for(;;); -new Array(); diff --git a/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es5.2.minified.js b/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es5.2.minified.js index 6a6c7a8a89f..4ab96f09617 100644 --- a/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/validMultipleVariableDeclarations_es5.2.minified.js @@ -1,2 +1 @@ for(;;); -new Array(); diff --git a/crates/swc_ecma_minifier/src/compress/pure/misc.rs b/crates/swc_ecma_minifier/src/compress/pure/misc.rs index 75b55141934..f2ebaf722fc 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/misc.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/misc.rs @@ -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 { diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js index 28ccc638195..ac2ee9c31ee 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-core/1/output.js @@ -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) { diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js index 9f9c3b9b6ab..e5dac1b876f 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js @@ -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) { diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-17.0.1.js b/crates/swc_ecma_minifier/tests/projects/output/react-17.0.1.js index b2ce1afd5e6..bde0001bf05 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-17.0.1.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-17.0.1.js @@ -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, diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js index e151f768981..fc6b774b64d 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js @@ -8932,15 +8932,7 @@ } hasBadMapPolyfill = !1; try { - var nonExtensibleObject = Object.preventExtensions({}); - new Map([ - [ - nonExtensibleObject, - null - ] - ]), new Set([ - nonExtensibleObject - ]); + Object.preventExtensions({}); } catch (e) { hasBadMapPolyfill = !0; }