Skip to content

Commit

Permalink
feat(es/minifier): Remove useless ES version check (#5703)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Aug 31, 2022
1 parent c92a836 commit 5e2b6d5
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import _class_private_field_set from "@swc/helpers/src/_class_private_field_set.
let friendA;
var _x = new WeakMap();
friendA = {
getX (obj) {
return _class_private_field_get(obj, _x);
},
getX: (obj)=>_class_private_field_get(obj, _x),
setX (obj, value) {
_class_private_field_set(obj, _x, value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [computedPropertyNamesContextualType6_ES6.ts]
foo({
p: "",
0: ()=>{},
0 () {},
hibye: !0,
1: 0,
[NaN]: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [computedPropertyNamesContextualType7_ES6.ts]
foo({
0: ()=>{},
0 () {},
hibye: !0,
1: 0,
[NaN]: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export class cl1 {
}
}
export const obj = {
m: async ()=>{
async m () {
await import('./test');
}
};
export class cl2 {
constructor(){
this.p = {
m: async ()=>{
async m () {
await import('./test');
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export class C {
export class D {
}
Object.defineProperty(D.prototype, "x", {
get () {
return 12;
}
get: ()=>12
});
export class E {
}
Expand All @@ -28,8 +26,6 @@ Object.defineProperty(E.prototype, "x", {
export class F {
}
Object.defineProperty(F.prototype, "x", {
get () {
return 12;
},
get: ()=>12,
set (_arg) {}
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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++;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//// [symbolProperty18.ts]
var i = {
[Symbol.iterator]: 0,
[Symbol.toStringTag] () {
return "";
},
[Symbol.toStringTag]: ()=>"",
set [Symbol.toPrimitive] (p){}
};
i[Symbol.iterator], i[Symbol.toStringTag](), i[Symbol.toPrimitive] = !1;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ var i = {
[Symbol.iterator]: {
p: null
},
[Symbol.toStringTag] () {
return {
[Symbol.toStringTag]: ()=>({
p: void 0
};
}
})
};
i[Symbol.iterator], i[Symbol.toStringTag]();
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ Object.defineProperty(exports, "__esModule", {
ClassWithPrivateNamedAccessors: ()=>ClassWithPrivateNamedAccessors
});
const obj = {
method1 (p) {
return p;
},
method2 (p) {
return p;
}
method1: (p)=>p,
method2: (p)=>p
}, classExpression = class {
method1(p) {
return p;
Expand Down
4 changes: 0 additions & 4 deletions crates/swc_ecma_minifier/src/compress/pure/arrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ impl Pure<'_> {
}

pub(super) fn optimize_arrow_method_prop(&mut self, p: &mut Prop) {
if self.options.ecma < EsVersion::Es2015 {
return;
}

if !self.options.unsafe_methods && !self.options.arrows {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3985,7 +3985,7 @@
const c = s.createWebChannel(o, r);
let a = !1, u = !1;
const h = new Gr({
vi: (t)=>{
vi (t) {
u ? $("Connection", "Not sending because WebChannel is closed:", t) : (a || ($("Connection", "Opening WebChannel transport."), c.open(), a = !0), $("Connection", "WebChannel sending:", t), c.send(t));
},
Vi: ()=>c.close()
Expand Down Expand Up @@ -6060,7 +6060,7 @@
const s = new Q();
return t.asyncQueue.enqueueAndForget(async ()=>(function(t, e, n, s, i) {
const r = new Lc({
next: (n)=>{
next (n) {
e.enqueueAndForget(()=>Uo(t, o)), n.fromCache && "server" === s.source ? i.reject(new j(K.UNAVAILABLE, 'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')) : i.resolve(n);
},
error: (t)=>i.reject(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ export default function createWidgetsManager(onWidgetsUpdate) {
}));
}
return {
registerWidget (widget) {
return widgets.push(widget), scheduleUpdate(), function() {
registerWidget: (widget)=>(widgets.push(widget), scheduleUpdate(), function() {
widgets.splice(widgets.indexOf(widget), 1), scheduleUpdate();
};
},
}),
update: scheduleUpdate,
getWidgets () {
return widgets;
}
getWidgets: ()=>widgets
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ export default function createInstantSearchManager({ indexName , initialState ={
}));
}
return {
registerWidget (widget) {
return widgets.push(widget), scheduleUpdate(), function() {
registerWidget: (widget)=>(widgets.push(widget), scheduleUpdate(), function() {
widgets.splice(widgets.indexOf(widget), 1), scheduleUpdate();
};
},
}),
update: scheduleUpdate,
getWidgets () {
return widgets;
}
getWidgets: ()=>widgets
};
}(function() {
const metadata = getMetadata(store.getState().widgets);
Expand Down
Loading

1 comment on commit 5e2b6d5

@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: 5e2b6d5 Previous: 217f519 Ratio
es/full/minify/libraries/antd 1821920362 ns/iter (± 90947875) 1677891530 ns/iter (± 41356638) 1.09
es/full/minify/libraries/d3 427983819 ns/iter (± 26934166) 419187061 ns/iter (± 5636473) 1.02
es/full/minify/libraries/echarts 1643506948 ns/iter (± 104485965) 1498701275 ns/iter (± 47655445) 1.10
es/full/minify/libraries/jquery 106044655 ns/iter (± 13529282) 106195833 ns/iter (± 7582977) 1.00
es/full/minify/libraries/lodash 154522692 ns/iter (± 14201652) 123029401 ns/iter (± 3000002) 1.26
es/full/minify/libraries/moment 69997401 ns/iter (± 6745917) 55787501 ns/iter (± 1133520) 1.25
es/full/minify/libraries/react 22261824 ns/iter (± 2201811) 20107229 ns/iter (± 703480) 1.11
es/full/minify/libraries/terser 311374549 ns/iter (± 12113085) 325413688 ns/iter (± 11135578) 0.96
es/full/minify/libraries/three 646120933 ns/iter (± 55315880) 582426714 ns/iter (± 15984180) 1.11
es/full/minify/libraries/typescript 3810794826 ns/iter (± 209055496) 3582327869 ns/iter (± 72147446) 1.06
es/full/minify/libraries/victory 871569918 ns/iter (± 35316521) 783705825 ns/iter (± 29957498) 1.11
es/full/minify/libraries/vue 168669466 ns/iter (± 15711745) 137690572 ns/iter (± 5411997) 1.22
es/full/codegen/es3 34621 ns/iter (± 4107) 32773 ns/iter (± 2431) 1.06
es/full/codegen/es5 37182 ns/iter (± 6122) 32641 ns/iter (± 1405) 1.14
es/full/codegen/es2015 35220 ns/iter (± 5661) 32271 ns/iter (± 2854) 1.09
es/full/codegen/es2016 34069 ns/iter (± 2432) 32630 ns/iter (± 1324) 1.04
es/full/codegen/es2017 33396 ns/iter (± 1275) 32346 ns/iter (± 831) 1.03
es/full/codegen/es2018 34562 ns/iter (± 5329) 32603 ns/iter (± 1371) 1.06
es/full/codegen/es2019 34101 ns/iter (± 2644) 32666 ns/iter (± 769) 1.04
es/full/codegen/es2020 34446 ns/iter (± 3113) 32608 ns/iter (± 791) 1.06
es/full/all/es3 219976149 ns/iter (± 21463440) 193313101 ns/iter (± 7248931) 1.14
es/full/all/es5 205944915 ns/iter (± 23402468) 179992260 ns/iter (± 11420472) 1.14
es/full/all/es2015 149533394 ns/iter (± 8907653) 144716500 ns/iter (± 3796720) 1.03
es/full/all/es2016 146086797 ns/iter (± 9053141) 143907593 ns/iter (± 3698600) 1.02
es/full/all/es2017 146663267 ns/iter (± 7767725) 144523676 ns/iter (± 6275469) 1.01
es/full/all/es2018 143997287 ns/iter (± 6227957) 147395625 ns/iter (± 7190814) 0.98
es/full/all/es2019 150611977 ns/iter (± 8624138) 142517484 ns/iter (± 90797611) 1.06
es/full/all/es2020 143488765 ns/iter (± 8257756) 137680017 ns/iter (± 6775815) 1.04
es/full/parser 803174 ns/iter (± 80333) 743527 ns/iter (± 25459) 1.08
es/full/base/fixer 28458 ns/iter (± 3017) 29435 ns/iter (± 2097) 0.97
es/full/base/resolver_and_hygiene 86900 ns/iter (± 4181) 88573 ns/iter (± 12171) 0.98
serialization of ast node 221 ns/iter (± 31) 213 ns/iter (± 3) 1.04
serialization of serde 244 ns/iter (± 25) 229 ns/iter (± 1) 1.07

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

Please sign in to comment.