-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Don't inline a callable expression if it's used as …
…a reference (#5118)
- Loading branch information
Showing
70 changed files
with
90,321 additions
and
2,147 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
crates/swc/tests/fixture/issues-2xxx/2011/reduced/output/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
var a; | ||
var a, b = function() {}; | ||
module.exports = ((a = function() { | ||
"use strict"; | ||
function a() {} | ||
return a.prototype.it = function() { | ||
this.bb = new a.MyA(); | ||
}, a; | ||
}()).MyA = function() {}, a); | ||
}()).MyA = b, a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...ces/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
var A; | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
!function(A) { | ||
var Point = function() { | ||
var fromOrigin = function(p) { | ||
return new Line({ | ||
x: 0, | ||
y: 0 | ||
}, p); | ||
}, Point = function() { | ||
"use strict"; | ||
_class_call_check(this, Point); | ||
}; | ||
A.Point = Point; | ||
var Line = function(start, end) { | ||
var Line = function Line(start, end) { | ||
"use strict"; | ||
_class_call_check(this, Line), this.start = start, this.end = end; | ||
}; | ||
A.Line = Line, A.fromOrigin = function(p) { | ||
return new Line({ | ||
x: 0, | ||
y: 0 | ||
}, p); | ||
}; | ||
A.Line = Line, A.fromOrigin = fromOrigin; | ||
}(A || (A = {})); |
16 changes: 8 additions & 8 deletions
16
...references/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
var A; | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
!function(A) { | ||
var Point = function() { | ||
"use strict"; | ||
_class_call_check(this, Point); | ||
}, Line = function(start, end) { | ||
"use strict"; | ||
_class_call_check(this, Line), this.start = start, this.end = end; | ||
}; | ||
A.Line = Line, A.fromOrigin = function(p) { | ||
var fromOrigin = function(p) { | ||
return new Line({ | ||
x: 0, | ||
y: 0 | ||
}, p); | ||
}, Point = function() { | ||
"use strict"; | ||
_class_call_check(this, Point); | ||
}, Line = function Line(start, end) { | ||
"use strict"; | ||
_class_call_check(this, Line), this.start = start, this.end = end; | ||
}; | ||
A.Line = Line, A.fromOrigin = fromOrigin; | ||
}(A || (A = {})); |
16 changes: 8 additions & 8 deletions
16
...sc-references/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
var A; | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
!function(A) { | ||
var Point = function() { | ||
var fromOrigin = function(p) { | ||
return new Line({ | ||
x: 0, | ||
y: 0 | ||
}, p); | ||
}, Point = function() { | ||
"use strict"; | ||
_class_call_check(this, Point); | ||
}; | ||
A.Point = Point; | ||
var Line = function(start, end) { | ||
var Line = function Line(start, end) { | ||
"use strict"; | ||
_class_call_check(this, Line), this.start = start, this.end = end; | ||
}; | ||
A.fromOrigin = function(p) { | ||
return new Line({ | ||
x: 0, | ||
y: 0 | ||
}, p); | ||
}; | ||
A.fromOrigin = fromOrigin; | ||
}(A || (A = {})); |
13 changes: 8 additions & 5 deletions
13
crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
...ests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedFunctions_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var A; | ||
!function(A) { | ||
A.fn = function(s) { | ||
var fn = function(s) { | ||
return !0; | ||
}, A.fng = function(s) { | ||
}, fng = function(s) { | ||
return null; | ||
}; | ||
A.fn = fn, A.fng = fng; | ||
}(A || (A = {})), A.fn, A.fng, A.fn2, A.fng2; |
7 changes: 4 additions & 3 deletions
7
crates/swc/tests/tsc-references/commonJSAliasedExport_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
var donkey = function(ast) { | ||
return ast; | ||
}; | ||
function funky(declaration) { | ||
return !1; | ||
} | ||
module.exports = function(ast) { | ||
return ast; | ||
}, module.exports.funky = funky; | ||
module.exports = donkey, module.exports.funky = funky; | ||
var funky = require("./commonJSAliasedExport").funky; | ||
funky(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
crates/swc/tests/tsc-references/exportAssignmentMergedModule_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 9 additions & 5 deletions
14
crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
crates/swc/tests/tsc-references/importStatementsInterfaces_es5.2.minified.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
var C, D, E; | ||
C || (C = {}), D || (D = {}), (E || (E = {})).xDist = function(x) { | ||
return 0 - x.x; | ||
}; | ||
C || (C = {}), D || (D = {}), function(E) { | ||
var xDist = function(x) { | ||
return 0 - x.x; | ||
}; | ||
E.xDist = xDist; | ||
}(E || (E = {})); |
Oops, something went wrong.
0e4a03c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/minify/libraries/antd
1772791159
ns/iter (± 78467817
)1786169866
ns/iter (± 114204135
)0.99
es/full/minify/libraries/d3
466364990
ns/iter (± 51301912
)446747396
ns/iter (± 37105310
)1.04
es/full/minify/libraries/echarts
1816227662
ns/iter (± 217842083
)1771580421
ns/iter (± 154631986
)1.03
es/full/minify/libraries/jquery
129542528
ns/iter (± 47596669
)109026497
ns/iter (± 12684919
)1.19
es/full/minify/libraries/lodash
160789279
ns/iter (± 7215569
)144098234
ns/iter (± 24390314
)1.12
es/full/minify/libraries/moment
69011659
ns/iter (± 3230079
)63348313
ns/iter (± 2143507
)1.09
es/full/minify/libraries/react
20433374
ns/iter (± 2123365
)20510033
ns/iter (± 4704088
)1.00
es/full/minify/libraries/terser
646052205
ns/iter (± 11160829
)649541915
ns/iter (± 43724176
)0.99
es/full/minify/libraries/three
596606779
ns/iter (± 87425911
)612941308
ns/iter (± 98882614
)0.97
es/full/minify/libraries/typescript
3783381764
ns/iter (± 377411365
)3806066704
ns/iter (± 253310375
)0.99
es/full/minify/libraries/victory
765078488
ns/iter (± 46436322
)782409336
ns/iter (± 93927600
)0.98
es/full/minify/libraries/vue
157639120
ns/iter (± 13193365
)169646197
ns/iter (± 3503812
)0.93
es/full/codegen/es3
32674
ns/iter (± 700
)33785
ns/iter (± 3313
)0.97
es/full/codegen/es5
32421
ns/iter (± 808
)33206
ns/iter (± 1961
)0.98
es/full/codegen/es2015
32668
ns/iter (± 6188
)33757
ns/iter (± 1810
)0.97
es/full/codegen/es2016
32498
ns/iter (± 1061
)32308
ns/iter (± 440
)1.01
es/full/codegen/es2017
32438
ns/iter (± 1815
)32349
ns/iter (± 631
)1.00
es/full/codegen/es2018
32522
ns/iter (± 4958
)32363
ns/iter (± 1679
)1.00
es/full/codegen/es2019
32714
ns/iter (± 921
)32393
ns/iter (± 2240
)1.01
es/full/codegen/es2020
32345
ns/iter (± 600
)32562
ns/iter (± 1168
)0.99
es/full/all/es3
208943121
ns/iter (± 28156658
)211461222
ns/iter (± 15372153
)0.99
es/full/all/es5
190442358
ns/iter (± 56673963
)199556462
ns/iter (± 13351772
)0.95
es/full/all/es2015
167122727
ns/iter (± 46598022
)153561301
ns/iter (± 11863103
)1.09
es/full/all/es2016
163782319
ns/iter (± 40752940
)147012169
ns/iter (± 16109374
)1.11
es/full/all/es2017
165281731
ns/iter (± 23282599
)149891256
ns/iter (± 11582520
)1.10
es/full/all/es2018
165276077
ns/iter (± 31520258
)145951194
ns/iter (± 13584130
)1.13
es/full/all/es2019
163802190
ns/iter (± 36834062
)153206771
ns/iter (± 13002580
)1.07
es/full/all/es2020
148630830
ns/iter (± 28040043
)145877834
ns/iter (± 13970615
)1.02
es/full/parser
728682
ns/iter (± 23592
)718437
ns/iter (± 33157
)1.01
es/full/base/fixer
29644
ns/iter (± 1111
)29593
ns/iter (± 8246
)1.00
es/full/base/resolver_and_hygiene
90341
ns/iter (± 3965
)88694
ns/iter (± 8881
)1.02
serialization of ast node
217
ns/iter (± 4
)217
ns/iter (± 10
)1
serialization of serde
230
ns/iter (± 14
)228
ns/iter (± 5
)1.01
This comment was automatically generated by workflow using github-action-benchmark.