Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/minifier): Inline a lazily initialized var if it's used once (#…
- Loading branch information
Showing
150 changed files
with
5,719 additions
and
6,084 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 t, n = function() {}; | ||
var t; | ||
module.exports = ((t = function() { | ||
"use strict"; | ||
function t() {} | ||
return t.prototype.it = function() { | ||
this.bb = new t.MyA(); | ||
}, t; | ||
}()).MyA = n, t); | ||
}()).MyA = function() {}, t); |
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
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
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
11 changes: 4 additions & 7 deletions
11
...ests/tsc-references/ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.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,10 +1,7 @@ | ||
//// [ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.ts] | ||
var A; | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
!function(A) { | ||
var points = function points() { | ||
"use strict"; | ||
_class_call_check(this, points); | ||
}; | ||
A.points = points; | ||
}(A || (A = {})); | ||
(A || (A = {})).points = function points() { | ||
"use strict"; | ||
_class_call_check(this, points); | ||
}; |
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
13 changes: 5 additions & 8 deletions
13
crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.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: 5 additions & 8 deletions
13
...wc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.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
11 changes: 4 additions & 7 deletions
11
crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.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,12 +1,9 @@ | ||
//// [ModuleAndEnumWithSameNameAndCommonRoot.ts] | ||
var enumdule; | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
!function(enumdule) { | ||
var Point = function Point(x, y) { | ||
"use strict"; | ||
_class_call_check(this, Point), this.x = x, this.y = y; | ||
}; | ||
enumdule.Point = Point; | ||
}(enumdule || (enumdule = {})), function(enumdule) { | ||
(enumdule || (enumdule = {})).Point = function Point(x, y) { | ||
"use strict"; | ||
_class_call_check(this, Point), this.x = x, this.y = y; | ||
}, function(enumdule) { | ||
enumdule[enumdule.Red = 0] = "Red", enumdule[enumdule.Blue = 1] = "Blue"; | ||
}(enumdule || (enumdule = {})), enumdule.Red, new enumdule.Point(0, 0); |
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: 2 additions & 3 deletions
5
crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedFunctions.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,10 +1,9 @@ | ||
//// [ModuleWithExportedAndNonExportedFunctions.ts] | ||
var A; | ||
!function(A) { | ||
var fn = function(s) { | ||
A.fn = function(s) { | ||
return !0; | ||
}, fng = function(s) { | ||
}, A.fng = function(s) { | ||
return null; | ||
}; | ||
A.fn = fn, A.fng = fng; | ||
}(A || (A = {})), A.fn, A.fng, A.fn2, A.fng2; |
11 changes: 4 additions & 7 deletions
11
crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.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
Oops, something went wrong.
1cd7f61
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/bugs-1
353134
ns/iter (± 23624
)387271
ns/iter (± 44005
)0.91
es/full/minify/libraries/antd
2003422775
ns/iter (± 95379472
)1919425798
ns/iter (± 69578682
)1.04
es/full/minify/libraries/d3
393512456
ns/iter (± 26057663
)439895874
ns/iter (± 9446188
)0.89
es/full/minify/libraries/echarts
1595531601
ns/iter (± 49723844
)1623574929
ns/iter (± 86070476
)0.98
es/full/minify/libraries/jquery
107226852
ns/iter (± 3040026
)116698378
ns/iter (± 2073008
)0.92
es/full/minify/libraries/lodash
127385981
ns/iter (± 5666823
)130046915
ns/iter (± 7912521
)0.98
es/full/minify/libraries/moment
65590309
ns/iter (± 5409223
)67110690
ns/iter (± 3357764
)0.98
es/full/minify/libraries/react
20245785
ns/iter (± 589418
)22592359
ns/iter (± 1594457
)0.90
es/full/minify/libraries/terser
301288772
ns/iter (± 7120226
)342963771
ns/iter (± 18168980
)0.88
es/full/minify/libraries/three
556002101
ns/iter (± 11301833
)544570838
ns/iter (± 18009687
)1.02
es/full/minify/libraries/typescript
3498194254
ns/iter (± 24193106
)3392895098
ns/iter (± 61855995
)1.03
es/full/minify/libraries/victory
826508015
ns/iter (± 27791646
)836893368
ns/iter (± 32989528
)0.99
es/full/minify/libraries/vue
152861674
ns/iter (± 8117361
)159378942
ns/iter (± 6815178
)0.96
es/full/codegen/es3
33445
ns/iter (± 2668
)34252
ns/iter (± 1631
)0.98
es/full/codegen/es5
32972
ns/iter (± 1990
)34251
ns/iter (± 2242
)0.96
es/full/codegen/es2015
33018
ns/iter (± 1029
)33984
ns/iter (± 855
)0.97
es/full/codegen/es2016
33419
ns/iter (± 1244
)33691
ns/iter (± 1486
)0.99
es/full/codegen/es2017
33515
ns/iter (± 2177
)33807
ns/iter (± 2128
)0.99
es/full/codegen/es2018
33471
ns/iter (± 1561
)33949
ns/iter (± 1012
)0.99
es/full/codegen/es2019
33261
ns/iter (± 1290
)34066
ns/iter (± 701
)0.98
es/full/codegen/es2020
33341
ns/iter (± 2198
)34042
ns/iter (± 502
)0.98
es/full/all/es3
192213712
ns/iter (± 5798939
)201231846
ns/iter (± 10537410
)0.96
es/full/all/es5
184069799
ns/iter (± 11196660
)181233095
ns/iter (± 19041028
)1.02
es/full/all/es2015
147950504
ns/iter (± 6188334
)146046126
ns/iter (± 5716949
)1.01
es/full/all/es2016
147359785
ns/iter (± 4348433
)154544399
ns/iter (± 15929619
)0.95
es/full/all/es2017
146394924
ns/iter (± 6031887
)153665769
ns/iter (± 12731676
)0.95
es/full/all/es2018
144612224
ns/iter (± 6461588
)146092101
ns/iter (± 10370831
)0.99
es/full/all/es2019
143663662
ns/iter (± 3699310
)138399647
ns/iter (± 5247802
)1.04
es/full/all/es2020
138507480
ns/iter (± 3443548
)134339039
ns/iter (± 5818882
)1.03
es/full/parser
724381
ns/iter (± 27667
)705046
ns/iter (± 30302
)1.03
es/full/base/fixer
26016
ns/iter (± 1276
)25879
ns/iter (± 976
)1.01
es/full/base/resolver_and_hygiene
89616
ns/iter (± 3567
)90517
ns/iter (± 8647
)0.99
serialization of ast node
212
ns/iter (± 11
)212
ns/iter (± 7
)1
serialization of serde
217
ns/iter (± 11
)218
ns/iter (± 3
)1.00
This comment was automatically generated by workflow using github-action-benchmark.