-
-
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(html): Prepare processing system (#4358)
- Loading branch information
1 parent
9dc30a5
commit 7332dce
Showing
236 changed files
with
45,485 additions
and
86,287 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
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,9 +1,101 @@ | ||
use swc_common::{ast_node, Span}; | ||
|
||
use crate::TokenAndSpan; | ||
use is_macro::Is; | ||
use string_enum::StringEnum; | ||
use swc_atoms::JsWord; | ||
use swc_common::{ast_node, EqIgnoreSpan, Span}; | ||
|
||
#[ast_node("Document")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct Document { | ||
pub span: Span, | ||
pub children: Vec<TokenAndSpan>, | ||
pub mode: DocumentMode, | ||
pub children: Vec<Child>, | ||
} | ||
|
||
#[ast_node("DocumentFragment")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct DocumentFragment { | ||
pub span: Span, | ||
pub children: Vec<Child>, | ||
} | ||
|
||
#[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] | ||
pub enum DocumentMode { | ||
/// `no-quirks` | ||
NoQuirks, | ||
/// `limited-quirks` | ||
LimitedQuirks, | ||
/// `quirks` | ||
Quirks, | ||
} | ||
|
||
#[ast_node] | ||
#[derive(Eq, Hash, Is, EqIgnoreSpan)] | ||
pub enum Child { | ||
#[tag("DocumentType")] | ||
DocumentType(DocumentType), | ||
#[tag("Element")] | ||
Element(Element), | ||
#[tag("Text")] | ||
Text(Text), | ||
#[tag("Comment")] | ||
Comment(Comment), | ||
} | ||
|
||
#[ast_node("DocumentType")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct DocumentType { | ||
pub span: Span, | ||
pub name: Option<JsWord>, | ||
pub public_id: Option<JsWord>, | ||
pub system_id: Option<JsWord>, | ||
} | ||
|
||
#[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash, EqIgnoreSpan)] | ||
pub enum Namespace { | ||
/// `http://www.w3.org/1999/xhtml` | ||
HTML, | ||
/// `http://www.w3.org/1998/Math/MathML` | ||
MATHML, | ||
/// `http://www.w3.org/2000/svg` | ||
SVG, | ||
/// `http://www.w3.org/1999/xlink` | ||
XLINK, | ||
/// `http://www.w3.org/XML/1998/namespace` | ||
XML, | ||
/// `http://www.w3.org/2000/xmlns/` | ||
XMLNS, | ||
} | ||
|
||
#[ast_node("Element")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct Element { | ||
pub span: Span, | ||
pub tag_name: JsWord, | ||
pub namespace: Namespace, | ||
pub attributes: Vec<Attribute>, | ||
pub children: Vec<Child>, | ||
/// For child nodes in `<template>` | ||
pub content: Option<DocumentFragment>, | ||
} | ||
|
||
#[ast_node("Attribute")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct Attribute { | ||
pub span: Span, | ||
pub name: JsWord, | ||
pub value: Option<JsWord>, | ||
} | ||
|
||
#[ast_node("Text")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct Text { | ||
pub span: Span, | ||
pub value: JsWord, | ||
} | ||
|
||
#[ast_node("Comment")] | ||
#[derive(Eq, Hash, EqIgnoreSpan)] | ||
pub struct Comment { | ||
pub span: Span, | ||
pub data: JsWord, | ||
} |
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
Oops, something went wrong.
7332dce
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
1602259968
ns/iter (± 43549633
)2552465738
ns/iter (± 124507091
)0.63
es/full/minify/libraries/d3
426383442
ns/iter (± 5555515
)600648137
ns/iter (± 19620317
)0.71
es/full/minify/libraries/echarts
1909834370
ns/iter (± 11813138
)3144898562
ns/iter (± 51151977
)0.61
es/full/minify/libraries/jquery
105621629
ns/iter (± 843146
)139784337
ns/iter (± 7902042
)0.76
es/full/minify/libraries/lodash
119402926
ns/iter (± 823578
)162960508
ns/iter (± 6090384
)0.73
es/full/minify/libraries/moment
60474757
ns/iter (± 325408
)80461651
ns/iter (± 3509229
)0.75
es/full/minify/libraries/react
19353444
ns/iter (± 70613
)26230435
ns/iter (± 884690
)0.74
es/full/minify/libraries/terser
529298873
ns/iter (± 6931923
)925435640
ns/iter (± 30032460
)0.57
es/full/minify/libraries/three
531183737
ns/iter (± 6927260
)744081935
ns/iter (± 28074439
)0.71
es/full/minify/libraries/typescript
3836045289
ns/iter (± 11035690
)5912197461
ns/iter (± 85444071
)0.65
es/full/minify/libraries/victory
732373713
ns/iter (± 15308025
)1102947452
ns/iter (± 61775176
)0.66
es/full/minify/libraries/vue
144848961
ns/iter (± 870313
)196198597
ns/iter (± 4702274
)0.74
es/full/codegen/es3
30357
ns/iter (± 155
)42160
ns/iter (± 4316
)0.72
es/full/codegen/es5
30370
ns/iter (± 127
)39761
ns/iter (± 2239
)0.76
es/full/codegen/es2015
30366
ns/iter (± 124
)40302
ns/iter (± 2212
)0.75
es/full/codegen/es2016
30336
ns/iter (± 167
)41305
ns/iter (± 2111
)0.73
es/full/codegen/es2017
30321
ns/iter (± 134
)40505
ns/iter (± 3536
)0.75
es/full/codegen/es2018
30306
ns/iter (± 133
)41000
ns/iter (± 3263
)0.74
es/full/codegen/es2019
30366
ns/iter (± 140
)39712
ns/iter (± 1890
)0.76
es/full/codegen/es2020
30375
ns/iter (± 154
)40684
ns/iter (± 2769
)0.75
es/full/all/es3
183929230
ns/iter (± 370673
)251361024
ns/iter (± 12942151
)0.73
es/full/all/es5
173014332
ns/iter (± 323973
)234386818
ns/iter (± 8745324
)0.74
es/full/all/es2015
133091430
ns/iter (± 314481
)188657226
ns/iter (± 6133841
)0.71
es/full/all/es2016
131977410
ns/iter (± 446585
)185595835
ns/iter (± 7145046
)0.71
es/full/all/es2017
131276292
ns/iter (± 434109
)182905285
ns/iter (± 8273283
)0.72
es/full/all/es2018
129160011
ns/iter (± 544527
)183141968
ns/iter (± 8063663
)0.71
es/full/all/es2019
128440169
ns/iter (± 612223
)182330111
ns/iter (± 7529178
)0.70
es/full/all/es2020
121957276
ns/iter (± 340005
)176413756
ns/iter (± 8105626
)0.69
es/full/parser
574030
ns/iter (± 11330
)813388
ns/iter (± 62515
)0.71
es/full/base/fixer
21733
ns/iter (± 265
)38082
ns/iter (± 2127
)0.57
es/full/base/resolver_and_hygiene
125506
ns/iter (± 1723
)190257
ns/iter (± 11975
)0.66
serialization of ast node
141
ns/iter (± 0
)187
ns/iter (± 8
)0.75
serialization of serde
143
ns/iter (± 0
)187
ns/iter (± 12
)0.76
es/codegen/colors
128495
ns/iter (± 70784
)71392
ns/iter (± 4862
)1.80
es/codegen/large
255147
ns/iter (± 1930
)413902
ns/iter (± 149396
)0.62
es/codegen/with-parser/colors
54426
ns/iter (± 404
)76938
ns/iter (± 5241
)0.71
es/codegen/with-parser/large
583009
ns/iter (± 5254
)818881
ns/iter (± 41813
)0.71
es/minify/libraries/antd
1572572839
ns/iter (± 40847569
)2449486973
ns/iter (± 54436559
)0.64
es/minify/libraries/d3
421911488
ns/iter (± 4484195
)603552999
ns/iter (± 18409836
)0.70
es/minify/libraries/echarts
1864784404
ns/iter (± 12879962
)3106527243
ns/iter (± 49975518
)0.60
es/minify/libraries/jquery
101941588
ns/iter (± 252556
)136651929
ns/iter (± 4735852
)0.75
es/minify/libraries/lodash
117168363
ns/iter (± 552053
)156366663
ns/iter (± 3815344
)0.75
es/minify/libraries/moment
59024268
ns/iter (± 290080
)79696711
ns/iter (± 3645811
)0.74
es/minify/libraries/react
18854659
ns/iter (± 39805
)26095477
ns/iter (± 1688423
)0.72
es/minify/libraries/terser
533600269
ns/iter (± 4577877
)899639618
ns/iter (± 30449111
)0.59
es/minify/libraries/three
515087135
ns/iter (± 7369306
)764040199
ns/iter (± 32018452
)0.67
es/minify/libraries/typescript
3773325541
ns/iter (± 15410239
)5809600821
ns/iter (± 57122328
)0.65
es/minify/libraries/victory
717161774
ns/iter (± 10556408
)1058779127
ns/iter (± 25511542
)0.68
es/minify/libraries/vue
143174775
ns/iter (± 815310
)192042095
ns/iter (± 3888777
)0.75
es/visitor/compare/clone
2348687
ns/iter (± 43699
)3319049
ns/iter (± 237840
)0.71
es/visitor/compare/visit_mut_span
2849657
ns/iter (± 20217
)3909641
ns/iter (± 269148
)0.73
es/visitor/compare/visit_mut_span_panic
2869313
ns/iter (± 14042
)3992568
ns/iter (± 291174
)0.72
es/visitor/compare/fold_span
4061878
ns/iter (± 23583
)5605528
ns/iter (± 436445
)0.72
es/visitor/compare/fold_span_panic
4328436
ns/iter (± 38096
)5785392
ns/iter (± 745361
)0.75
es/lexer/colors
20242
ns/iter (± 71
)27183
ns/iter (± 1536
)0.74
es/lexer/angular
10133627
ns/iter (± 11207
)12750544
ns/iter (± 604224
)0.79
es/lexer/backbone
1342388
ns/iter (± 1060
)1811964
ns/iter (± 129716
)0.74
es/lexer/jquery
7337912
ns/iter (± 4914
)9600920
ns/iter (± 608986
)0.76
es/lexer/jquery mobile
11814615
ns/iter (± 8741
)15308134
ns/iter (± 633472
)0.77
es/lexer/mootools
5680047
ns/iter (± 4205
)7206537
ns/iter (± 373488
)0.79
es/lexer/underscore
1124395
ns/iter (± 1440
)1462318
ns/iter (± 198395
)0.77
es/lexer/three
33887183
ns/iter (± 17036
)42110413
ns/iter (± 1732327
)0.80
es/lexer/yui
6183757
ns/iter (± 5995
)7866215
ns/iter (± 307962
)0.79
es/parser/colors
36893
ns/iter (± 166
)48982
ns/iter (± 2497
)0.75
es/parser/angular
18601367
ns/iter (± 178878
)24543587
ns/iter (± 1461120
)0.76
es/parser/backbone
2582237
ns/iter (± 12957
)3534966
ns/iter (± 232943
)0.73
es/parser/jquery
14200619
ns/iter (± 116290
)21033801
ns/iter (± 2292708
)0.68
es/parser/jquery mobile
22305036
ns/iter (± 375416
)34120390
ns/iter (± 2560359
)0.65
es/parser/mootools
11243378
ns/iter (± 182096
)16434717
ns/iter (± 1176220
)0.68
es/parser/underscore
2217531
ns/iter (± 8479
)3005130
ns/iter (± 167876
)0.74
es/parser/three
64989716
ns/iter (± 474844
)90500971
ns/iter (± 6507708
)0.72
es/parser/yui
11151267
ns/iter (± 51017
)16141240
ns/iter (± 1389990
)0.69
es/preset-env/usage/builtin_type
128288
ns/iter (± 3843
)186411
ns/iter (± 22277
)0.69
es/preset-env/usage/property
28275
ns/iter (± 335
)46813
ns/iter (± 4661
)0.60
es/transforms/base/resolver
136055
ns/iter (± 2156
)218366
ns/iter (± 15485
)0.62
es/transforms/base/fixer
118421
ns/iter (± 1264
)197147
ns/iter (± 12739
)0.60
es/transforms/base/hygiene
349744
ns/iter (± 3716
)511803
ns/iter (± 24238
)0.68
es/transforms/base/resolver_with_hygiene
415628
ns/iter (± 4046
)615623
ns/iter (± 38277
)0.68
es/visitor/base-perf/module_clone
82036
ns/iter (± 1798
)144661
ns/iter (± 8312
)0.57
es/visitor/base-perf/fold_empty
92530
ns/iter (± 2340
)162310
ns/iter (± 7208
)0.57
es/visitor/base-perf/fold_noop_impl_all
92502
ns/iter (± 2212
)166883
ns/iter (± 8729
)0.55
es/visitor/base-perf/fold_noop_impl_vec
93099
ns/iter (± 2392
)164884
ns/iter (± 9496
)0.56
es/visitor/base-perf/boxing_boxed_clone
67
ns/iter (± 0
)88
ns/iter (± 3
)0.76
es/visitor/base-perf/boxing_unboxed_clone
93
ns/iter (± 1
)151
ns/iter (± 6
)0.62
es/visitor/base-perf/boxing_boxed
146
ns/iter (± 0
)171
ns/iter (± 7
)0.85
es/visitor/base-perf/boxing_unboxed
156
ns/iter (± 0
)230
ns/iter (± 12
)0.68
es/visitor/base-perf/visit_contains_this
3114
ns/iter (± 17
)5634
ns/iter (± 705
)0.55
misc/visitors/time-complexity/time 5
99
ns/iter (± 0
)127
ns/iter (± 7
)0.78
misc/visitors/time-complexity/time 10
293
ns/iter (± 8
)413
ns/iter (± 26
)0.71
misc/visitors/time-complexity/time 15
597
ns/iter (± 1
)816
ns/iter (± 75
)0.73
misc/visitors/time-complexity/time 20
1261
ns/iter (± 56
)1498
ns/iter (± 129
)0.84
misc/visitors/time-complexity/time 40
5605
ns/iter (± 79
)5767
ns/iter (± 296
)0.97
misc/visitors/time-complexity/time 60
12203
ns/iter (± 81
)12196
ns/iter (± 897
)1.00
es/full-target/es2016
245889
ns/iter (± 3902
)352832
ns/iter (± 19863
)0.70
es/full-target/es2017
228801
ns/iter (± 3108
)337124
ns/iter (± 22483
)0.68
es/full-target/es2018
218273
ns/iter (± 2636
)348796
ns/iter (± 29875
)0.63
es2020_nullish_coalescing
104636
ns/iter (± 2269
)191179
ns/iter (± 14963
)0.55
es2020_optional_chaining
134334
ns/iter (± 1595
)220870
ns/iter (± 13447
)0.61
es2022_class_properties
138496
ns/iter (± 1436
)232556
ns/iter (± 15943
)0.60
es2018_object_rest_spread
97140
ns/iter (± 1654
)168317
ns/iter (± 35973
)0.58
es2019_optional_catch_binding
84287
ns/iter (± 1503
)154737
ns/iter (± 13003
)0.54
es2017_async_to_generator
84414
ns/iter (± 1560
)152222
ns/iter (± 10782
)0.55
es2016_exponentiation
104513
ns/iter (± 1138
)181139
ns/iter (± 21535
)0.58
es2015_arrow
106965
ns/iter (± 1719
)183277
ns/iter (± 14965
)0.58
es2015_block_scoped_fn
107528
ns/iter (± 1203
)177871
ns/iter (± 13145
)0.60
es2015_block_scoping
167305
ns/iter (± 4370
)290655
ns/iter (± 23723
)0.58
es2015_classes
157045
ns/iter (± 2461
)251011
ns/iter (± 22943
)0.63
es2015_computed_props
85762
ns/iter (± 2091
)155178
ns/iter (± 11528
)0.55
es2015_destructuring
166693
ns/iter (± 1803
)259030
ns/iter (± 25300
)0.64
es2015_duplicate_keys
88005
ns/iter (± 1166
)157862
ns/iter (± 16913
)0.56
es2015_parameters
115399
ns/iter (± 1577
)190864
ns/iter (± 13711
)0.60
es2015_fn_name
87468
ns/iter (± 2044
)157843
ns/iter (± 15276
)0.55
es2015_for_of
104722
ns/iter (± 1962
)169943
ns/iter (± 16001
)0.62
es2015_instanceof
96554
ns/iter (± 1068
)163628
ns/iter (± 22520
)0.59
es2015_shorthand_property
84782
ns/iter (± 1267
)147340
ns/iter (± 7719
)0.58
es2015_spread
85006
ns/iter (± 1788
)154467
ns/iter (± 14670
)0.55
es2015_sticky_regex
85413
ns/iter (± 2250
)154538
ns/iter (± 12289
)0.55
es2015_typeof_symbol
86238
ns/iter (± 1084
)150775
ns/iter (± 16712
)0.57
es/transform/baseline/base
73474
ns/iter (± 1655
)145398
ns/iter (± 15202
)0.51
es/transform/baseline/common_reserved_word
86631
ns/iter (± 1169
)155190
ns/iter (± 14287
)0.56
es/transform/baseline/common_typescript
195992
ns/iter (± 1462
)340246
ns/iter (± 38738
)0.58
es/target/es3
246503
ns/iter (± 1934
)365272
ns/iter (± 37518
)0.67
es/target/es2015
744181
ns/iter (± 14718
)1009772
ns/iter (± 111974
)0.74
es/target/es2016
105304
ns/iter (± 1253
)192085
ns/iter (± 21437
)0.55
es/target/es2017
84724
ns/iter (± 1328
)157446
ns/iter (± 17404
)0.54
es/target/es2018
109273
ns/iter (± 2047
)189668
ns/iter (± 18473
)0.58
es/target/es2020
174431
ns/iter (± 2535
)270659
ns/iter (± 27628
)0.64
babelify-only
679194
ns/iter (± 16606
)1068000
ns/iter (± 110365
)0.64
parse_and_babelify_angular
67673693
ns/iter (± 588678
)102558866
ns/iter (± 8925818
)0.66
parse_and_babelify_backbone
7516363
ns/iter (± 132149
)10063725
ns/iter (± 1075736
)0.75
parse_and_babelify_jquery
47828624
ns/iter (± 240208
)68813529
ns/iter (± 5709967
)0.70
parse_and_babelify_jquery_mobile
81753890
ns/iter (± 985631
)117516494
ns/iter (± 8038133
)0.70
parse_and_babelify_mootools
37413297
ns/iter (± 269682
)57184115
ns/iter (± 4740272
)0.65
parse_and_babelify_underscore
6260204
ns/iter (± 53968
)8763400
ns/iter (± 913925
)0.71
parse_and_babelify_yui
39482112
ns/iter (± 427709
)58788861
ns/iter (± 5834527
)0.67
This comment was automatically generated by workflow using github-action-benchmark.