-
-
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.
feat(bindings/ts): Add transform/strip-only mode (#9138)
**Description:** This PR adds `strip-only`/`transform` mode to `@swc/wasm-typescript`. - Both mode errors on decorator usages. - In `strip-only` mode, `enum` and TypeScript parameter properties are treated as an invalid syntax. - In `transform` mode, those are transpiled.
- Loading branch information
Showing
6 changed files
with
147 additions
and
35 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
bindings/binding_typescript_wasm/__tests__/__snapshots__/transform.js.snap
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`transform in strip-only mode should throw an error when it encounters an enum 1`] = ` | ||
" | ||
x TypeScript enum is not supported in strip-only mode | ||
,---- | ||
1 | enum Foo {} | ||
: ^^^^^^^^^^^ | ||
\`---- | ||
" | ||
`; | ||
|
||
exports[`transform in strip-only mode should throw an error with a descriptive message when it encounters a decorator 1`] = ` | ||
" | ||
x Decorators are not supported | ||
,---- | ||
1 | class Foo { @decorator foo() {} } | ||
: ^^^^^^^^^^ | ||
\`---- | ||
" | ||
`; | ||
|
||
exports[`transform in transform mode should transpile enum 1`] = ` | ||
"var Foo; | ||
(function(Foo) {})(Foo || (Foo = {})); | ||
" | ||
`; | ||
|
||
exports[`transform should strip types 1`] = ` | ||
"export const foo = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"jest": "^25.1.0" | ||
"jest": "^29.7.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
a08bb46
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
290444
ns/iter (± 11329
)301771
ns/iter (± 6748
)0.96
es/full/minify/libraries/antd
1919643974
ns/iter (± 39937062
)1679291084
ns/iter (± 46799885
)1.14
es/full/minify/libraries/d3
369732041
ns/iter (± 10433843
)336739979
ns/iter (± 670182
)1.10
es/full/minify/libraries/echarts
1633511802
ns/iter (± 25080120
)1399853705
ns/iter (± 6262393
)1.17
es/full/minify/libraries/jquery
105947919
ns/iter (± 1073274
)102026459
ns/iter (± 205356
)1.04
es/full/minify/libraries/lodash
116070843
ns/iter (± 1397781
)113615177
ns/iter (± 258867
)1.02
es/full/minify/libraries/moment
60237809
ns/iter (± 516760
)59185002
ns/iter (± 135460
)1.02
es/full/minify/libraries/react
18544967
ns/iter (± 80259
)18270975
ns/iter (± 25046
)1.01
es/full/minify/libraries/terser
289015517
ns/iter (± 3680925
)271521397
ns/iter (± 1142233
)1.06
es/full/minify/libraries/three
532464539
ns/iter (± 14539340
)461223702
ns/iter (± 2460040
)1.15
es/full/minify/libraries/typescript
3393879322
ns/iter (± 31340716
)3179084968
ns/iter (± 25659583
)1.07
es/full/minify/libraries/victory
859388278
ns/iter (± 12896313
)709760070
ns/iter (± 4775932
)1.21
es/full/minify/libraries/vue
149384965
ns/iter (± 3610406
)144783597
ns/iter (± 885745
)1.03
es/full/codegen/es3
61743
ns/iter (± 321
)61006
ns/iter (± 161
)1.01
es/full/codegen/es5
61697
ns/iter (± 392
)61066
ns/iter (± 1468
)1.01
es/full/codegen/es2015
61912
ns/iter (± 258
)61053
ns/iter (± 171
)1.01
es/full/codegen/es2016
61978
ns/iter (± 925
)60773
ns/iter (± 80
)1.02
es/full/codegen/es2017
61517
ns/iter (± 420
)60813
ns/iter (± 110
)1.01
es/full/codegen/es2018
62083
ns/iter (± 1865
)60748
ns/iter (± 128
)1.02
es/full/codegen/es2019
61879
ns/iter (± 679
)60833
ns/iter (± 181
)1.02
es/full/codegen/es2020
61971
ns/iter (± 341
)60737
ns/iter (± 155
)1.02
es/full/all/es3
162917119
ns/iter (± 1523645
)159100409
ns/iter (± 848319
)1.02
es/full/all/es5
155320780
ns/iter (± 700581
)155416769
ns/iter (± 1731604
)1.00
es/full/all/es2015
114913448
ns/iter (± 713962
)114715259
ns/iter (± 926245
)1.00
es/full/all/es2016
113797638
ns/iter (± 544166
)113861589
ns/iter (± 394355
)1.00
es/full/all/es2017
113084848
ns/iter (± 763135
)113430769
ns/iter (± 491948
)1.00
es/full/all/es2018
111102906
ns/iter (± 868264
)111832777
ns/iter (± 1163355
)0.99
es/full/all/es2019
110682679
ns/iter (± 617166
)110325047
ns/iter (± 611321
)1.00
es/full/all/es2020
106876427
ns/iter (± 1680727
)106999560
ns/iter (± 861239
)1.00
es/full/parser
448232
ns/iter (± 2667
)447662
ns/iter (± 2604
)1.00
es/full/base/fixer
15225
ns/iter (± 47
)15042
ns/iter (± 64
)1.01
es/full/base/resolver_and_hygiene
79593
ns/iter (± 308
)78858
ns/iter (± 218
)1.01
serialization of serde
275
ns/iter (± 3
)268
ns/iter (± 2
)1.03
css/minify/libraries/bootstrap
21936479
ns/iter (± 97063
)21937143
ns/iter (± 312751
)1.00
css/visitor/compare/clone
1353511
ns/iter (± 18952
)1371753
ns/iter (± 16028
)0.99
css/visitor/compare/visit_mut_span
1469416
ns/iter (± 13358
)1489510
ns/iter (± 8766
)0.99
css/visitor/compare/visit_mut_span_panic
1494622
ns/iter (± 42148
)1504999
ns/iter (± 34645
)0.99
css/visitor/compare/fold_span
1984316
ns/iter (± 8419
)1989771
ns/iter (± 4991
)1.00
css/visitor/compare/fold_span_panic
2119241
ns/iter (± 9306
)2133063
ns/iter (± 5795
)0.99
css/lexer/bootstrap_5_1_3
3584321
ns/iter (± 3275
)3459110
ns/iter (± 7341
)1.04
css/lexer/foundation_6_7_4
2906519
ns/iter (± 4083
)2798793
ns/iter (± 4825
)1.04
css/lexer/tailwind_3_1_1
538160
ns/iter (± 2367
)536828
ns/iter (± 414
)1.00
css/parser/bootstrap_5_1_3
15928586
ns/iter (± 29585
)16267961
ns/iter (± 111758
)0.98
css/parser/foundation_6_7_4
12758930
ns/iter (± 37874
)12894975
ns/iter (± 22222
)0.99
css/parser/tailwind_3_1_1
2514324
ns/iter (± 11131
)2546975
ns/iter (± 3000
)0.99
es/codegen/colors
729536
ns/iter (± 399819
)726333
ns/iter (± 397454
)1.00
es/codegen/large
3050743
ns/iter (± 1603353
)3022400
ns/iter (± 1590152
)1.01
es/codegen/with-parser/colors
40444
ns/iter (± 164
)40693
ns/iter (± 837
)0.99
es/codegen/with-parser/large
448522
ns/iter (± 1803
)450998
ns/iter (± 5477
)0.99
es/minify/libraries/antd
1438832597
ns/iter (± 24767526
)1590184932
ns/iter (± 25192746
)0.90
es/minify/libraries/d3
289745767
ns/iter (± 12145482
)301942190
ns/iter (± 6150069
)0.96
es/minify/libraries/echarts
1122852597
ns/iter (± 25491846
)1301964778
ns/iter (± 8155507
)0.86
es/minify/libraries/jquery
82517539
ns/iter (± 358545
)83242909
ns/iter (± 464600
)0.99
es/minify/libraries/lodash
104080290
ns/iter (± 249885
)105150852
ns/iter (± 234890
)0.99
es/minify/libraries/moment
48248486
ns/iter (± 51682
)48795112
ns/iter (± 536301
)0.99
es/minify/libraries/react
16152015
ns/iter (± 144039
)16372557
ns/iter (± 68062
)0.99
es/minify/libraries/terser
216390656
ns/iter (± 513870
)224222141
ns/iter (± 1656403
)0.97
es/minify/libraries/three
360324734
ns/iter (± 905676
)397611980
ns/iter (± 4214017
)0.91
es/minify/libraries/typescript
2630339254
ns/iter (± 14722096
)2880515103
ns/iter (± 28346585
)0.91
es/minify/libraries/victory
545029280
ns/iter (± 2706248
)702683937
ns/iter (± 10023678
)0.78
es/minify/libraries/vue
120785971
ns/iter (± 250688
)123156965
ns/iter (± 486496
)0.98
es/visitor/compare/clone
1753108
ns/iter (± 16550
)1736257
ns/iter (± 4300
)1.01
es/visitor/compare/visit_mut_span
2089428
ns/iter (± 28396
)2065484
ns/iter (± 10916
)1.01
es/visitor/compare/visit_mut_span_panic
2099444
ns/iter (± 35948
)2072945
ns/iter (± 58144
)1.01
es/visitor/compare/fold_span
2834028
ns/iter (± 60960
)2802599
ns/iter (± 29383
)1.01
es/visitor/compare/fold_span_panic
2836701
ns/iter (± 44190
)2835664
ns/iter (± 8788
)1.00
es/lexer/colors
9523
ns/iter (± 75
)10189
ns/iter (± 64
)0.93
es/lexer/angular
5116519
ns/iter (± 89296
)5236375
ns/iter (± 19198
)0.98
es/lexer/backbone
630410
ns/iter (± 3549
)707902
ns/iter (± 10783
)0.89
es/lexer/jquery
3613749
ns/iter (± 35358
)3956533
ns/iter (± 30265
)0.91
es/lexer/jquery mobile
5344058
ns/iter (± 31957
)5783746
ns/iter (± 21812
)0.92
es/lexer/mootools
2862085
ns/iter (± 9789
)3149624
ns/iter (± 14081
)0.91
es/lexer/underscore
528694
ns/iter (± 1260
)583192
ns/iter (± 2501
)0.91
es/lexer/three
16263681
ns/iter (± 114870
)17298443
ns/iter (± 81455
)0.94
es/lexer/yui
2907493
ns/iter (± 23784
)3100132
ns/iter (± 6548
)0.94
es/lexer/cal-com
13377768
ns/iter (± 101784
)14036647
ns/iter (± 58942
)0.95
es/lexer/typescript
93673108
ns/iter (± 471174
)96652966
ns/iter (± 276784
)0.97
es/parser/colors
23545
ns/iter (± 169
)23225
ns/iter (± 88
)1.01
es/parser/angular
13439478
ns/iter (± 322269
)12416758
ns/iter (± 59366
)1.08
es/parser/backbone
1835089
ns/iter (± 9165
)1822925
ns/iter (± 7311
)1.01
es/parser/jquery
10388832
ns/iter (± 187625
)10088462
ns/iter (± 54211
)1.03
es/parser/jquery mobile
16224802
ns/iter (± 222844
)15111839
ns/iter (± 79243
)1.07
es/parser/mootools
7937615
ns/iter (± 38401
)7772375
ns/iter (± 10950
)1.02
es/parser/underscore
1602648
ns/iter (± 15183
)1580789
ns/iter (± 4738
)1.01
es/parser/three
47351913
ns/iter (± 504535
)43514804
ns/iter (± 208253
)1.09
es/parser/yui
7533113
ns/iter (± 41515
)7375556
ns/iter (± 32021
)1.02
es/parser/cal-com
42371594
ns/iter (± 456989
)39357716
ns/iter (± 252776
)1.08
es/parser/typescript
277725641
ns/iter (± 5198669
)267470477
ns/iter (± 906666
)1.04
es/preset-env/usage/builtin_type
136543
ns/iter (± 33312
)136654
ns/iter (± 33947
)1.00
es/preset-env/usage/property
16156
ns/iter (± 113
)16470
ns/iter (± 82
)0.98
es/resolver/typescript
102716443
ns/iter (± 4237227
)101233255
ns/iter (± 1287530
)1.01
es/fixer/typescript
79697487
ns/iter (± 3143434
)82210730
ns/iter (± 2615835
)0.97
es/hygiene/typescript
172552387
ns/iter (± 2586506
)182730344
ns/iter (± 4263215
)0.94
es/resolver_with_hygiene/typescript
299018894
ns/iter (± 3223204
)305641375
ns/iter (± 3233015
)0.98
es/visitor/base-perf/module_clone
56724
ns/iter (± 450
)57379
ns/iter (± 357
)0.99
es/visitor/base-perf/fold_empty
59851
ns/iter (± 830
)60615
ns/iter (± 889
)0.99
es/visitor/base-perf/fold_noop_impl_all
60047
ns/iter (± 629
)60362
ns/iter (± 498
)0.99
es/visitor/base-perf/fold_noop_impl_vec
60265
ns/iter (± 1108
)60360
ns/iter (± 319
)1.00
es/visitor/base-perf/boxing_boxed_clone
62
ns/iter (± 0
)60
ns/iter (± 0
)1.03
es/visitor/base-perf/boxing_unboxed_clone
47
ns/iter (± 0
)47
ns/iter (± 0
)1
es/visitor/base-perf/boxing_boxed
107
ns/iter (± 0
)105
ns/iter (± 0
)1.02
es/visitor/base-perf/boxing_unboxed
82
ns/iter (± 0
)80
ns/iter (± 0
)1.02
es/visitor/base-perf/visit_contains_this
2574
ns/iter (± 31
)2609
ns/iter (± 11
)0.99
es/base/parallel/resolver/typescript
2508501125
ns/iter (± 136885041
)2534515067
ns/iter (± 149542798
)0.99
es/base/parallel/hygiene/typescript
3243120328
ns/iter (± 60426990
)3266219904
ns/iter (± 69585890
)0.99
babelify-only
493802
ns/iter (± 4464
)493743
ns/iter (± 2381
)1.00
parse_and_babelify_angular
45122341
ns/iter (± 617537
)41387641
ns/iter (± 1026672
)1.09
parse_and_babelify_backbone
4515594
ns/iter (± 220547
)4339388
ns/iter (± 172199
)1.04
parse_and_babelify_jquery
29431163
ns/iter (± 234154
)29118425
ns/iter (± 620332
)1.01
parse_and_babelify_jquery_mobile
53746501
ns/iter (± 863653
)50235688
ns/iter (± 454495
)1.07
parse_and_babelify_mootools
26850579
ns/iter (± 293320
)24889197
ns/iter (± 218270
)1.08
parse_and_babelify_underscore
3711911
ns/iter (± 60291
)3701760
ns/iter (± 16735
)1.00
parse_and_babelify_yui
25153713
ns/iter (± 305656
)23192121
ns/iter (± 149270
)1.08
html/minify/document/css_spec
46155378
ns/iter (± 165581
)49045769
ns/iter (± 1027504
)0.94
html/minify/document/github
18335846
ns/iter (± 35863
)19402960
ns/iter (± 199259
)0.95
html/minify/document/stackoverflow
16757708
ns/iter (± 480318
)17523825
ns/iter (± 288830
)0.96
html/minify/document_fragment/css_spec
44480700
ns/iter (± 1090662
)48277495
ns/iter (± 1376575
)0.92
html/minify/document_fragment/github
17995464
ns/iter (± 59423
)19448121
ns/iter (± 375679
)0.93
html/minify/document_fragment/stackoverflow
16267061
ns/iter (± 6450
)17312314
ns/iter (± 170557
)0.94
html/document/visitor/compare/clone
166601
ns/iter (± 1948
)166053
ns/iter (± 1721
)1.00
html/document/visitor/compare/visit_mut_span
182604
ns/iter (± 1840
)183492
ns/iter (± 3712
)1.00
html/document/visitor/compare/visit_mut_span_panic
190077
ns/iter (± 1071
)187784
ns/iter (± 7144
)1.01
html/document/visitor/compare/fold_span
232454
ns/iter (± 2421
)228154
ns/iter (± 1419
)1.02
html/document/visitor/compare/fold_span_panic
282064
ns/iter (± 748
)280688
ns/iter (± 1529
)1.00
html/document_fragment/visitor/compare/clone
168531
ns/iter (± 818
)166216
ns/iter (± 727
)1.01
html/document_fragment/visitor/compare/visit_mut_span
182277
ns/iter (± 970
)181909
ns/iter (± 692
)1.00
html/document_fragment/visitor/compare/visit_mut_span_panic
187148
ns/iter (± 1499
)188268
ns/iter (± 1774
)0.99
html/document_fragment/visitor/compare/fold_span
232168
ns/iter (± 1815
)230314
ns/iter (± 1608
)1.01
html/document_fragment/visitor/compare/fold_span_panic
282022
ns/iter (± 1439
)277635
ns/iter (± 5127
)1.02
html/lexer/css_2021_spec
12752234
ns/iter (± 21004
)12938142
ns/iter (± 21560
)0.99
html/lexer/github_com_17_05_2022
4894552
ns/iter (± 12082
)4944257
ns/iter (± 12047
)0.99
html/lexer/stackoverflow_com_17_05_2022
4651680
ns/iter (± 25403
)4672849
ns/iter (± 13368
)1.00
html/parser/parser_document/css_2021_spec
25003075
ns/iter (± 116315
)25313968
ns/iter (± 46346
)0.99
html/parser/parser_document/github_com_17_05_2022
8406505
ns/iter (± 15898
)8399552
ns/iter (± 26743
)1.00
html/parser/parser_document/stackoverflow_com_17_05_2022
7306296
ns/iter (± 20130
)7335424
ns/iter (± 127694
)1.00
html/parser/parser_document_fragment/css_2021_spec
24543117
ns/iter (± 45562
)24833812
ns/iter (± 335667
)0.99
html/parser/parser_document_fragment/github_com_17_05_2022
8310681
ns/iter (± 11841
)8324046
ns/iter (± 9489
)1.00
html/parser/parser_document_fragment/stackoverflow_com_17_05_2022
7280095
ns/iter (± 12504
)7276445
ns/iter (± 8850
)1.00
This comment was automatically generated by workflow using github-action-benchmark.