-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webpack/ast): Fix amd support (#2959)
swc_webpack_ast: - `ast_reducer`: Preserve array literals in `define` calls.
- Loading branch information
Showing
7 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
4 changes: 3 additions & 1 deletion
4
crates/swc_webpack_ast/tests/fixture/amd/define-required/1/output.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,5 +1,7 @@ | ||
export function foo() { | ||
define("require", function(r) { | ||
define([ | ||
"require" | ||
], function(r) { | ||
r("lodash"); | ||
}); | ||
} |
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,2 +1,2 @@ | ||
if (null) module.exports; | ||
else if (define, define.amd) define(null, null); | ||
else if (define, define.amd) define([], null); |
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 +1,4 @@ | ||
module, require("react"), define, define.amd, define("react", null); | ||
module, require("react"), define, define.amd, define([ | ||
"exports", | ||
"react" | ||
], null); |
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 +1,4 @@ | ||
module, require("react"), define, define.amd, define("react", null); | ||
module, require("react"), define, define.amd, define([ | ||
"exports", | ||
"react" | ||
], null); |
eda514b
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
base_tr_fixer
30817
ns/iter (± 3384
)33716
ns/iter (± 4445
)0.91
base_tr_resolver_and_hygiene
174115
ns/iter (± 25639
)173622
ns/iter (± 47450
)1.00
codegen_es2015
64197
ns/iter (± 4858
)62811
ns/iter (± 10950
)1.02
codegen_es2016
63929
ns/iter (± 7418
)69858
ns/iter (± 7885
)0.92
codegen_es2017
63590
ns/iter (± 5718
)60423
ns/iter (± 11081
)1.05
codegen_es2018
64525
ns/iter (± 6126
)65746
ns/iter (± 19792
)0.98
codegen_es2019
63781
ns/iter (± 5990
)73247
ns/iter (± 16557
)0.87
codegen_es2020
66863
ns/iter (± 6074
)69042
ns/iter (± 17133
)0.97
codegen_es3
64546
ns/iter (± 6737
)61508
ns/iter (± 13659
)1.05
codegen_es5
63889
ns/iter (± 6062
)60908
ns/iter (± 11748
)1.05
full_es2015
209270302
ns/iter (± 16131892
)205761718
ns/iter (± 27519501
)1.02
full_es2016
166224894
ns/iter (± 7299143
)168266838
ns/iter (± 23595267
)0.99
full_es2017
174488950
ns/iter (± 15584276
)175846208
ns/iter (± 27283896
)0.99
full_es2018
176481173
ns/iter (± 14887664
)170820891
ns/iter (± 27370619
)1.03
full_es2019
172072402
ns/iter (± 13311778
)160944621
ns/iter (± 31638358
)1.07
full_es2020
170193180
ns/iter (± 11153886
)163738848
ns/iter (± 38978174
)1.04
full_es3
243457134
ns/iter (± 52542565
)223713636
ns/iter (± 59028215
)1.09
full_es5
223986045
ns/iter (± 23463641
)206034713
ns/iter (± 31914899
)1.09
parser
816471
ns/iter (± 82159
)747448
ns/iter (± 108515
)1.09
ser_ast_node
173
ns/iter (± 19
)160
ns/iter (± 27
)1.08
ser_serde
171
ns/iter (± 15
)169
ns/iter (± 46
)1.01
emit_colors
11320693
ns/iter (± 6901475
)12220510
ns/iter (± 15382264
)0.93
emit_large
113095163
ns/iter (± 173563688
)69531607
ns/iter (± 98899020
)1.63
base_clone
2822484
ns/iter (± 227511
)2651690
ns/iter (± 361545
)1.06
fold_span
4674553
ns/iter (± 649098
)4409327
ns/iter (± 660800
)1.06
fold_span_panic
4913896
ns/iter (± 358791
)4777787
ns/iter (± 1049759
)1.03
visit_mut_span
3345630
ns/iter (± 328514
)3513389
ns/iter (± 740428
)0.95
visit_mut_span_panic
3356693
ns/iter (± 372984
)3459958
ns/iter (± 503433
)0.97
ast_clone
25417
ns/iter (± 2508
)21856
ns/iter (± 5309
)1.16
ast_clone_to_stable
76620
ns/iter (± 7382
)77047
ns/iter (± 17657
)0.99
ast_clone_to_stable_then_to_unstable
136865
ns/iter (± 22473
)139600
ns/iter (± 20718
)0.98
json_deserialize
2664261
ns/iter (± 453303
)2581640
ns/iter (± 353527
)1.03
json_serialize
111835
ns/iter (± 18128
)94624
ns/iter (± 15796
)1.18
boxing_boxed
151
ns/iter (± 15
)139
ns/iter (± 20
)1.09
boxing_boxed_clone
85
ns/iter (± 11
)78
ns/iter (± 12
)1.09
boxing_unboxed
143
ns/iter (± 17
)124
ns/iter (± 29
)1.15
boxing_unboxed_clone
73
ns/iter (± 9
)69
ns/iter (± 20
)1.06
time_10
380
ns/iter (± 38
)325
ns/iter (± 48
)1.17
time_15
811
ns/iter (± 68
)682
ns/iter (± 105
)1.19
time_20
1455
ns/iter (± 169
)1511
ns/iter (± 295
)0.96
time_40
5396
ns/iter (± 806
)5731
ns/iter (± 1116
)0.94
time_5
124
ns/iter (± 12
)106
ns/iter (± 19
)1.17
time_60
11701
ns/iter (± 1015
)10706
ns/iter (± 2187
)1.09
This comment was automatically generated by workflow using github-action-benchmark.