Skip to content

Commit

Permalink
fix(es/minifier): Change default es version to es5 (#5333)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jul 29, 2022
1 parent e896879 commit 64a9946
Show file tree
Hide file tree
Showing 54 changed files with 164 additions and 116 deletions.
Expand Up @@ -3,7 +3,7 @@ var M, ANY2 = [
""
], obj1 = {
x: "",
y () {}
y: ()=>{}
};
class A {
static foo() {}
Expand Down
Expand Up @@ -4,6 +4,6 @@ foo(1), foo(), f(1), f(), f2(1), f2(1, 2), c.foo(), c.foo(1), i(), i(1), i.foo(1
var b = {
foo (x) {},
a: function(x, y) {},
b (x) {}
b: (x)=>{}
};
b.foo(), b.foo(1), b.a(1), b.a(1, 2), b.b(), b.b(1);
Expand Up @@ -4,7 +4,9 @@ var A = function() {
this.b = 2;
};
exports.A = A, exports.B = B, A.prototype = B.prototype = {
m: (n)=>n + 1
m (n) {
return n + 1;
}
};
var mod = require('./mod'), a = new mod.A(), b = new mod.B();
a.m('nope'), b.m('not really');
Expand Up @@ -5,10 +5,14 @@ Object.defineProperty(exports, "thing", {
value: "Smith",
writable: !1
}), Object.defineProperty(exports, "rwAccessors", {
get: ()=>98122,
get () {
return 98122;
},
set (_) {}
}), Object.defineProperty(exports, "readonlyAccessor", {
get: ()=>21.75
get () {
return 21.75;
}
}), Object.defineProperty(exports, "setonlyAccessor", {
set (str) {
this.rwAccessors = Number(str);
Expand All @@ -21,10 +25,14 @@ Object.defineProperty(module.exports, "thing", {
value: "Smith",
writable: !1
}), Object.defineProperty(module.exports, "rwAccessors", {
get: ()=>98122,
get () {
return 98122;
},
set (_) {}
}), Object.defineProperty(module.exports, "readonlyAccessor", {
get: ()=>21.75
get () {
return 21.75;
}
}), Object.defineProperty(module.exports, "setonlyAccessor", {
set (str) {
this.rwAccessors = Number(str);
Expand Down
Expand Up @@ -10,10 +10,14 @@ Person.prototype.describe = function() {
value: "Smith",
writable: !1
}), Object.defineProperty(Person.prototype, "rwAccessors", {
get: ()=>98122,
get () {
return 98122;
},
set (_) {}
}), Object.defineProperty(Person.prototype, "readonlyAccessor", {
get: ()=>21.75
get () {
return 21.75;
}
}), Object.defineProperty(Person.prototype, "setonlyAccessor", {
set (str) {
this.rwAccessors = Number(str);
Expand Down
@@ -1,7 +1,9 @@
const obj = {
foo: void 0,
bar: "42",
method1: (n1)=>n1 + 42,
method1 (n1) {
return n1 + 42;
},
lol: "hello Lol",
bar1: 42,
arrowFunc: (num)=>num + 42
Expand Down
@@ -1,7 +1,9 @@
var lol;
const obj = {
bar: 42,
method1: (n1)=>"42",
method1 (n1) {
return "42";
},
method2: (n1)=>"lol",
arrowFunc: (num = "0")=>num + 42,
lol
Expand Down
Expand Up @@ -8,10 +8,14 @@ Object.defineProperty(x, "name", {
value: "Smith",
writable: !1
}), Object.defineProperty(x, "zip", {
get: ()=>98122,
get () {
return 98122;
},
set (_) {}
}), Object.defineProperty(x, "houseNumber", {
get: ()=>21.75
get () {
return 21.75;
}
}), Object.defineProperty(x, "zipStr", {
set (str) {
this.zip = Number(str);
Expand Down
Expand Up @@ -8,7 +8,9 @@ Object.defineProperty(exports, "thing", {
value: 42,
writable: !0
}), Object.defineProperty(exports, "bad1", {}), Object.defineProperty(exports, "bad2", {
get: ()=>12,
get () {
return 12;
},
value: "no"
}), Object.defineProperty(exports, "bad3", {
writable: !0
Expand Down
Expand Up @@ -4,7 +4,9 @@ import _class_private_field_set from "@swc/helpers/src/_class_private_field_set.
let friendA;
var _x = new WeakMap();
friendA = {
getX: (obj)=>_class_private_field_get(obj, _x),
getX (obj) {
return _class_private_field_get(obj, _x);
},
setX (obj, value) {
_class_private_field_set(obj, _x, value);
}
Expand Down
@@ -1,6 +1,6 @@
foo({
p: "",
0 () {},
0: ()=>{},
hibye: !0,
1: 0,
[NaN]: [
Expand Down
@@ -1,6 +1,6 @@
foo({
p: "",
0 () {},
0: ()=>{},
hibye: !0,
1: 0,
[NaN]: [
Expand Down
@@ -1,5 +1,5 @@
foo({
0 () {},
0: ()=>{},
hibye: !0,
1: 0,
[NaN]: [
Expand Down
@@ -1,5 +1,5 @@
foo({
0 () {},
0: ()=>{},
hibye: !0,
1: 0,
[NaN]: [
Expand Down
@@ -1,4 +1,6 @@
var x = {
a: (p)=>p
a (p) {
return p;
}
};
x.a(x);
Expand Up @@ -4,7 +4,7 @@ export function MainButton(props) {
return props.goTo ? this._buildMainLink(props) : this._buildMainButton(props);
}
_extends({}, {
onClick (k) {
onClick: (k)=>{
console.log(k);
}
}, {
Expand All @@ -16,7 +16,7 @@ _extends({}, {
});
export function NoOverload() {}
_extends({}, {
onClick (k) {
onClick: (k)=>{
console.log(k);
}
}, {
Expand Down
@@ -1,6 +1,8 @@
const TopLevelSym = Symbol(), InnerSym = Symbol();
module.exports = {
[TopLevelSym]: (x = 12)=>x,
[TopLevelSym] (x = 12) {
return x;
},
items: {
[InnerSym]: (arg = {
x: 12
Expand Down
Expand Up @@ -9,5 +9,7 @@ function Context(input) {
this.state = this.construct(input);
}
Context.prototype = {
construct: (input, handle = ()=>void 0)=>input
construct (input, handle = ()=>void 0) {
return input;
}
}, module.exports = Context;
Expand Up @@ -15,7 +15,9 @@ export class C {
export class D {
}
Object.defineProperty(D.prototype, "x", {
get: ()=>12
get () {
return 12;
}
});
export class E {
}
Expand All @@ -25,6 +27,8 @@ Object.defineProperty(E.prototype, "x", {
export class F {
}
Object.defineProperty(F.prototype, "x", {
get: ()=>12,
get () {
return 12;
},
set (_arg) {}
});
Expand Up @@ -2,9 +2,9 @@ var E, Flag;
!function(E) {
E[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C";
}(E || (E = {})), one(()=>{}), on({
test () {}
test: ()=>{}
}), on({
test (x) {}
test: (x)=>{}
}), new Component1({
data: {
hello: ""
Expand Down
Expand Up @@ -3,7 +3,7 @@ var M, ANY2 = [
""
], obj1 = {
x: "",
y () {}
y: ()=>{}
};
class A {
static foo() {}
Expand Down
Expand Up @@ -15,7 +15,9 @@ let o = {
explicitThis: function(m) {
return m + this.n.length;
},
implicitThis: (m)=>m
implicitThis (m) {
return m;
}
}, i = o;
(0, i.explicitThis)(12), (0, (void 0).implicitNoThis)(12), c.explicitVoid = c.implicitThis, o.implicitThis = c.implicitThis, o.implicitThis = c.explicitThis, o.implicitThis = i.explicitThis, i.explicitThis = function(m) {
return this.n.length;
Expand Down
Expand Up @@ -3,7 +3,7 @@ var M, ANY2 = [
""
], obj1 = {
x: "",
y () {}
y: ()=>{}
};
class A {
static foo() {}
Expand Down
Expand Up @@ -2,9 +2,11 @@ registerComponent('test-component', {
schema: {
myProperty: {
default: [],
parse: ()=>[
parse () {
return [
!0
]
];
}
},
string: {
type: 'string'
Expand Down
Expand Up @@ -2,7 +2,7 @@ class A {
}
c.valueOf(), c.data.hm, c.hm, i.valueOf(), i.data.hm, i.hm;
var c, i, b, a = {
valueOf () {},
valueOf: ()=>{},
data: new class extends A {
}()
};
Expand Down
@@ -1,4 +1,4 @@
var i, b;
(void 0).valueOf(), i.valueOf(), ({
valueOf () {}
valueOf: ()=>{}
}).valueOf(), b.valueOf();
Expand Up @@ -2,8 +2,8 @@ var M, ANY2 = [
"",
""
], obj1 = {
x (s) {},
y (s1) {}
x: (s)=>{},
y: (s1)=>{}
};
class A {
static foo() {}
Expand Down
Expand Up @@ -5,7 +5,7 @@ import _class_static_private_method_get from "@swc/helpers/src/_class_static_pri
class A3 {
constructor(a, b){
_class_static_private_field_spec_set(A3, A3, _method, ()=>{}), _class_static_private_field_spec_set(a, A3, _method, ()=>{}), _class_static_private_field_spec_set(b, A3, _method, ()=>{}), ({ x: _class_static_private_field_destructure(A3, A3, _method).value } = {
x () {}
x: ()=>{}
}), _class_static_private_method_get(A3, A3, function() {}), _class_static_private_field_update(b, A3, _method).value++;
}
}
@@ -1,6 +1,8 @@
var i = {
[Symbol.iterator]: 0,
[Symbol.toStringTag]: ()=>"",
[Symbol.toStringTag] () {
return "";
},
set [Symbol.toPrimitive] (p){}
};
i[Symbol.iterator], i[Symbol.toStringTag](), i[Symbol.toPrimitive] = !1;
Expand Up @@ -2,8 +2,10 @@ var i = {
[Symbol.iterator]: {
p: null
},
[Symbol.toStringTag]: ()=>({
[Symbol.toStringTag] () {
return {
p: void 0
})
};
}
};
i[Symbol.iterator], i[Symbol.toStringTag]();
Expand Up @@ -18,5 +18,7 @@ extend1({
foo (n) {
return n.length + this.bar();
},
bar: ()=>14
bar () {
return 14;
}
});
Expand Up @@ -18,7 +18,9 @@ function implicitThis(n) {
let impl = {
a: 12,
explicitVoid2: ()=>this.a,
explicitVoid1: ()=>12,
explicitVoid1 () {
return 12;
},
explicitStructural () {
return this.a;
},
Expand Down
Expand Up @@ -80,7 +80,9 @@ let vue = new Vue({
return this.x;
},
hello: {
get: ()=>"hi",
get () {
return "hi";
},
set (value) {}
}
}
Expand Down
Expand Up @@ -7,9 +7,7 @@ class TextComponent extends React.Component {
}
_extends({}, {
editable: !1
});
let textPropsTrue = {
}), _extends({}, {
editable: !0,
onEdit () {}
};
_extends({}, textPropsTrue);
onEdit: ()=>{}
});

1 comment on commit 64a9946

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 64a9946 Previous: add1b75 Ratio
es/full/minify/libraries/antd 1806238021 ns/iter (± 100429634) 1622447998 ns/iter (± 37731133) 1.11
es/full/minify/libraries/d3 458689603 ns/iter (± 33275540) 418982906 ns/iter (± 17744724) 1.09
es/full/minify/libraries/echarts 1753634635 ns/iter (± 126506590) 1563500521 ns/iter (± 36374416) 1.12
es/full/minify/libraries/jquery 117313212 ns/iter (± 2344835) 88827586 ns/iter (± 813573) 1.32
es/full/minify/libraries/lodash 153460236 ns/iter (± 13737784) 118249410 ns/iter (± 6464666) 1.30
es/full/minify/libraries/moment 66473435 ns/iter (± 6228911) 52127674 ns/iter (± 1173451) 1.28
es/full/minify/libraries/react 20843545 ns/iter (± 2397650) 17114045 ns/iter (± 420212) 1.22
es/full/minify/libraries/terser 324216858 ns/iter (± 39319665) 289323614 ns/iter (± 4290493) 1.12
es/full/minify/libraries/three 612515817 ns/iter (± 61392560) 536107219 ns/iter (± 2822790) 1.14
es/full/minify/libraries/typescript 3910479412 ns/iter (± 228321768) 3451130307 ns/iter (± 67592688) 1.13
es/full/minify/libraries/victory 800986046 ns/iter (± 78851358) 730022748 ns/iter (± 15282988) 1.10
es/full/minify/libraries/vue 169046136 ns/iter (± 12215771) 132949641 ns/iter (± 7088191) 1.27
es/full/codegen/es3 33825 ns/iter (± 2610) 32500 ns/iter (± 368) 1.04
es/full/codegen/es5 35612 ns/iter (± 5922) 32519 ns/iter (± 585) 1.10
es/full/codegen/es2015 36060 ns/iter (± 4498) 32548 ns/iter (± 746) 1.11
es/full/codegen/es2016 35629 ns/iter (± 3308) 32541 ns/iter (± 675) 1.09
es/full/codegen/es2017 34142 ns/iter (± 3193) 32559 ns/iter (± 1487) 1.05
es/full/codegen/es2018 33947 ns/iter (± 3153) 32540 ns/iter (± 901) 1.04
es/full/codegen/es2019 33795 ns/iter (± 3492) 32511 ns/iter (± 324) 1.04
es/full/codegen/es2020 33600 ns/iter (± 3626) 32503 ns/iter (± 410) 1.03
es/full/all/es3 224326953 ns/iter (± 20466628) 189070194 ns/iter (± 5666065) 1.19
es/full/all/es5 208733633 ns/iter (± 25037245) 176976052 ns/iter (± 4840554) 1.18
es/full/all/es2015 168221940 ns/iter (± 18177800) 145564230 ns/iter (± 4230758) 1.16
es/full/all/es2016 166942037 ns/iter (± 16404809) 144613591 ns/iter (± 7153291) 1.15
es/full/all/es2017 168036261 ns/iter (± 19277710) 144625881 ns/iter (± 5792735) 1.16
es/full/all/es2018 165433518 ns/iter (± 21191253) 142443814 ns/iter (± 4045583) 1.16
es/full/all/es2019 166971123 ns/iter (± 17031094) 141785394 ns/iter (± 6518611) 1.18
es/full/all/es2020 159042846 ns/iter (± 22935747) 137748710 ns/iter (± 4487375) 1.15
es/full/parser 816181 ns/iter (± 101448) 753299 ns/iter (± 30706) 1.08
es/full/base/fixer 30762 ns/iter (± 5320) 28875 ns/iter (± 452) 1.07
es/full/base/resolver_and_hygiene 91320 ns/iter (± 5078) 86765 ns/iter (± 4868) 1.05
serialization of ast node 217 ns/iter (± 16) 210 ns/iter (± 5) 1.03
serialization of serde 249 ns/iter (± 23) 227 ns/iter (± 2) 1.10

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.