-
-
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/react): Respect
import_source
in new jsx (#7128)
**Related issue:** - Closes #6987.
- Loading branch information
1 parent
aaaa9ca
commit 5d7acfd
Showing
6 changed files
with
59 additions
and
4 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
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
24 changes: 24 additions & 0 deletions
24
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6987/input.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { isValidElement, Children } from "react"; | ||
|
||
import * as styles from "./CheckmarkList.styles"; | ||
|
||
|
||
const CheckmarkList = ({ children}) => { | ||
const listItems = () => | ||
Children.map(children, (child, index) => { | ||
if (!isValidElement(child)) { | ||
return null; | ||
} | ||
const { children: liChildren, css: liCss, ...otherProps } = child.props; | ||
|
||
return ( | ||
<li {...otherProps} key={`checkmark-list-item-${index}`} css={[styles.listItem, liCss]}> | ||
{liChildren} | ||
</li> | ||
); | ||
}); | ||
|
||
return <ul css={styles.list}>{listItems()}</ul>; | ||
}; | ||
|
||
export { CheckmarkList }; |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6987/options.json
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,6 @@ | ||
{ | ||
"runtime": "automatic", | ||
"importSource": "@emotion/react", | ||
"pragma": "React.createElement", | ||
"pragmaFrag": "React.Fragment" | ||
} |
25 changes: 25 additions & 0 deletions
25
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6987/output.mjs
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,25 @@ | ||
import { jsx as _jsx } from "@emotion/react/jsx-runtime"; | ||
import { createElement as _createElement } from "@emotion/react"; | ||
import { isValidElement, Children } from "react"; | ||
import * as styles from "./CheckmarkList.styles"; | ||
const CheckmarkList = ({ children })=>{ | ||
const listItems = ()=>Children.map(children, (child, index)=>{ | ||
if (!/*#__PURE__*/ isValidElement(child)) { | ||
return null; | ||
} | ||
const { children: liChildren , css: liCss , ...otherProps } = child.props; | ||
return /*#__PURE__*/ _createElement("li", { | ||
...otherProps, | ||
key: `checkmark-list-item-${index}`, | ||
css: [ | ||
styles.listItem, | ||
liCss | ||
] | ||
}, liChildren); | ||
}); | ||
return /*#__PURE__*/ _jsx("ul", { | ||
css: styles.list, | ||
children: listItems() | ||
}); | ||
}; | ||
export { CheckmarkList }; |
5d7acfd
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
302553
ns/iter (± 6906
)299022
ns/iter (± 7720
)1.01
es/full/minify/libraries/antd
1496038502
ns/iter (± 14733616
)1581716619
ns/iter (± 20082308
)0.95
es/full/minify/libraries/d3
287658853
ns/iter (± 5515602
)290179118
ns/iter (± 6775157
)0.99
es/full/minify/libraries/echarts
1153195267
ns/iter (± 8054662
)1228145799
ns/iter (± 52550207
)0.94
es/full/minify/libraries/jquery
88496782
ns/iter (± 511299
)90195113
ns/iter (± 616045
)0.98
es/full/minify/libraries/lodash
103705814
ns/iter (± 463483
)105435329
ns/iter (± 817215
)0.98
es/full/minify/libraries/moment
51317499
ns/iter (± 374607
)51923558
ns/iter (± 469916
)0.99
es/full/minify/libraries/react
18932719
ns/iter (± 129531
)18835789
ns/iter (± 76177
)1.01
es/full/minify/libraries/terser
235445232
ns/iter (± 1898349
)239417756
ns/iter (± 3101333
)0.98
es/full/minify/libraries/three
414552815
ns/iter (± 4500112
)432026629
ns/iter (± 7242497
)0.96
es/full/minify/libraries/typescript
2884206273
ns/iter (± 15748565
)3081233106
ns/iter (± 26389602
)0.94
es/full/minify/libraries/victory
618783127
ns/iter (± 6269033
)648005227
ns/iter (± 6345590
)0.95
es/full/minify/libraries/vue
127677821
ns/iter (± 1040288
)129242387
ns/iter (± 828271
)0.99
es/full/codegen/es3
26466
ns/iter (± 92
)26697
ns/iter (± 65
)0.99
es/full/codegen/es5
26575
ns/iter (± 137
)26706
ns/iter (± 86
)1.00
es/full/codegen/es2015
26318
ns/iter (± 162
)26762
ns/iter (± 84
)0.98
es/full/codegen/es2016
26341
ns/iter (± 100
)26759
ns/iter (± 50
)0.98
es/full/codegen/es2017
26241
ns/iter (± 148
)26654
ns/iter (± 59
)0.98
es/full/codegen/es2018
26480
ns/iter (± 41
)26701
ns/iter (± 31
)0.99
es/full/codegen/es2019
26264
ns/iter (± 157
)26723
ns/iter (± 60
)0.98
es/full/codegen/es2020
26358
ns/iter (± 148
)26698
ns/iter (± 79
)0.99
es/full/all/es3
182822547
ns/iter (± 2301363
)180886295
ns/iter (± 3441118
)1.01
es/full/all/es5
173816410
ns/iter (± 3250289
)173247331
ns/iter (± 3773462
)1.00
es/full/all/es2015
139207630
ns/iter (± 1346174
)135822000
ns/iter (± 1100815
)1.02
es/full/all/es2016
135103225
ns/iter (± 1714089
)132386767
ns/iter (± 1617664
)1.02
es/full/all/es2017
134689698
ns/iter (± 1635066
)132551510
ns/iter (± 1509251
)1.02
es/full/all/es2018
130474510
ns/iter (± 1635985
)128470448
ns/iter (± 2420106
)1.02
es/full/all/es2019
127675167
ns/iter (± 1978064
)126974590
ns/iter (± 1188931
)1.01
es/full/all/es2020
118277948
ns/iter (± 763620
)118795291
ns/iter (± 947152
)1.00
es/full/parser
536005
ns/iter (± 9759
)536192
ns/iter (± 8270
)1.00
es/full/base/fixer
22136
ns/iter (± 96
)22147
ns/iter (± 52
)1.00
es/full/base/resolver_and_hygiene
82070
ns/iter (± 291
)82573
ns/iter (± 119
)0.99
serialization of ast node
123
ns/iter (± 0
)124
ns/iter (± 0
)0.99
serialization of serde
125
ns/iter (± 0
)126
ns/iter (± 0
)0.99
css/minify/libraries/bootstrap
28050632
ns/iter (± 221073
)29094328
ns/iter (± 138275
)0.96
css/visitor/compare/clone
2050067
ns/iter (± 14342
)2114944
ns/iter (± 8894
)0.97
css/visitor/compare/visit_mut_span
2235437
ns/iter (± 10774
)2255617
ns/iter (± 9948
)0.99
css/visitor/compare/visit_mut_span_panic
2301130
ns/iter (± 9016
)2341763
ns/iter (± 3468
)0.98
css/visitor/compare/fold_span
2989990
ns/iter (± 33999
)3013514
ns/iter (± 19142
)0.99
css/visitor/compare/fold_span_panic
3137873
ns/iter (± 24057
)3151385
ns/iter (± 20712
)1.00
css/lexer/bootstrap_5_1_3
5066299
ns/iter (± 22238
)5144725
ns/iter (± 12592
)0.98
css/lexer/foundation_6_7_4
4247144
ns/iter (± 21966
)4343855
ns/iter (± 16735
)0.98
css/lexer/tailwind_3_1_1
805460
ns/iter (± 4421
)822288
ns/iter (± 1042
)0.98
css/parser/bootstrap_5_1_3
21480061
ns/iter (± 159853
)21922827
ns/iter (± 26770
)0.98
css/parser/foundation_6_7_4
17276205
ns/iter (± 91112
)17449905
ns/iter (± 20153
)0.99
css/parser/tailwind_3_1_1
3296415
ns/iter (± 14473
)3362348
ns/iter (± 3974
)0.98
es/codegen/colors
328616
ns/iter (± 184629
)333368
ns/iter (± 188274
)0.99
es/codegen/large
1220512
ns/iter (± 617089
)1233471
ns/iter (± 633207
)0.99
es/codegen/with-parser/colors
47183
ns/iter (± 382
)47867
ns/iter (± 29
)0.99
es/codegen/with-parser/large
517576
ns/iter (± 3822
)521122
ns/iter (± 1131
)0.99
es/minify/libraries/antd
1275994030
ns/iter (± 13846345
)1330844121
ns/iter (± 31780799
)0.96
es/minify/libraries/d3
243240651
ns/iter (± 3831246
)242655531
ns/iter (± 2820744
)1.00
es/minify/libraries/echarts
999960383
ns/iter (± 7130262
)997797726
ns/iter (± 16430223
)1.00
es/minify/libraries/jquery
76966809
ns/iter (± 628038
)77093035
ns/iter (± 616895
)1.00
es/minify/libraries/lodash
91760101
ns/iter (± 546556
)92632061
ns/iter (± 962390
)0.99
es/minify/libraries/moment
44643568
ns/iter (± 245833
)45062816
ns/iter (± 287840
)0.99
es/minify/libraries/react
16681053
ns/iter (± 102178
)16776006
ns/iter (± 119711
)0.99
es/minify/libraries/terser
198757848
ns/iter (± 1456450
)203364906
ns/iter (± 3122593
)0.98
es/minify/libraries/three
339029890
ns/iter (± 6061783
)342558694
ns/iter (± 8008958
)0.99
es/minify/libraries/typescript
2414750383
ns/iter (± 10280795
)2544335647
ns/iter (± 16751578
)0.95
es/minify/libraries/victory
516687207
ns/iter (± 7143420
)525124391
ns/iter (± 9108094
)0.98
es/minify/libraries/vue
112742462
ns/iter (± 1181220
)112524449
ns/iter (± 790983
)1.00
es/visitor/compare/clone
2279655
ns/iter (± 23754
)2304972
ns/iter (± 11390
)0.99
es/visitor/compare/visit_mut_span
2620788
ns/iter (± 17211
)2649454
ns/iter (± 3810
)0.99
es/visitor/compare/visit_mut_span_panic
2679290
ns/iter (± 12436
)2683118
ns/iter (± 12697
)1.00
es/visitor/compare/fold_span
3703877
ns/iter (± 17106
)3739959
ns/iter (± 11500
)0.99
es/visitor/compare/fold_span_panic
3849014
ns/iter (± 23985
)3930198
ns/iter (± 5491
)0.98
es/lexer/colors
15326
ns/iter (± 148
)15385
ns/iter (± 47
)1.00
es/lexer/angular
7365220
ns/iter (± 33512
)7392769
ns/iter (± 23920
)1.00
es/lexer/backbone
984133
ns/iter (± 5733
)986297
ns/iter (± 2703
)1.00
es/lexer/jquery
5568788
ns/iter (± 25015
)5507724
ns/iter (± 38521
)1.01
es/lexer/jquery mobile
8442706
ns/iter (± 51365
)8562995
ns/iter (± 25816
)0.99
es/lexer/mootools
4358139
ns/iter (± 27472
)4380701
ns/iter (± 21446
)0.99
es/lexer/underscore
826737
ns/iter (± 6856
)827539
ns/iter (± 2430
)1.00
es/lexer/three
25710863
ns/iter (± 166284
)25922652
ns/iter (± 129071
)0.99
es/lexer/yui
4618783
ns/iter (± 19841
)4622287
ns/iter (± 20987
)1.00
es/parser/colors
28839
ns/iter (± 242
)29220
ns/iter (± 126
)0.99
es/parser/angular
14715860
ns/iter (± 114067
)14983099
ns/iter (± 192583
)0.98
es/parser/backbone
2202860
ns/iter (± 19087
)2191575
ns/iter (± 12877
)1.01
es/parser/jquery
12045920
ns/iter (± 199186
)11972400
ns/iter (± 120395
)1.01
es/parser/jquery mobile
18503571
ns/iter (± 138433
)18616327
ns/iter (± 153366
)0.99
es/parser/mootools
9158165
ns/iter (± 60051
)9273451
ns/iter (± 35355
)0.99
es/parser/underscore
1870994
ns/iter (± 16280
)1860381
ns/iter (± 16027
)1.01
es/parser/three
53378193
ns/iter (± 1251583
)52332658
ns/iter (± 586405
)1.02
es/parser/yui
9081689
ns/iter (± 76682
)9125162
ns/iter (± 72797
)1.00
es/preset-env/usage/builtin_type
139114
ns/iter (± 32624
)137988
ns/iter (± 31889
)1.01
es/preset-env/usage/property
21092
ns/iter (± 173
)21236
ns/iter (± 90
)0.99
es/resolver/typescript
112897033
ns/iter (± 2003860
)121311811
ns/iter (± 2102236
)0.93
es/fixer/typescript
77471261
ns/iter (± 311942
)85516571
ns/iter (± 1587307
)0.91
es/hygiene/typescript
161102812
ns/iter (± 1025981
)176390522
ns/iter (± 1837374
)0.91
es/resolver_with_hygiene/typescript
292645777
ns/iter (± 2149948
)311490994
ns/iter (± 3161439
)0.94
es/visitor/base-perf/module_clone
79036
ns/iter (± 945
)78771
ns/iter (± 1349
)1.00
es/visitor/base-perf/fold_empty
88308
ns/iter (± 1413
)88194
ns/iter (± 1343
)1.00
es/visitor/base-perf/fold_noop_impl_all
87712
ns/iter (± 1366
)89080
ns/iter (± 1276
)0.98
es/visitor/base-perf/fold_noop_impl_vec
89394
ns/iter (± 1195
)89814
ns/iter (± 1341
)1.00
es/visitor/base-perf/boxing_boxed_clone
55
ns/iter (± 0
)56
ns/iter (± 0
)0.98
es/visitor/base-perf/boxing_unboxed_clone
53
ns/iter (± 0
)53
ns/iter (± 0
)1
es/visitor/base-perf/boxing_boxed
101
ns/iter (± 0
)104
ns/iter (± 0
)0.97
es/visitor/base-perf/boxing_unboxed
97
ns/iter (± 0
)100
ns/iter (± 0
)0.97
es/visitor/base-perf/visit_contains_this
3533
ns/iter (± 75
)3464
ns/iter (± 113
)1.02
es/base/parallel/resolver/typescript
6373453601
ns/iter (± 253793935
)7154196527
ns/iter (± 474998219
)0.89
es/base/parallel/hygiene/typescript
1993644185
ns/iter (± 23329817
)2138769319
ns/iter (± 36727163
)0.93
misc/visitors/time-complexity/time 5
100
ns/iter (± 0
)100
ns/iter (± 0
)1
misc/visitors/time-complexity/time 10
332
ns/iter (± 0
)332
ns/iter (± 3
)1
misc/visitors/time-complexity/time 15
695
ns/iter (± 9
)695
ns/iter (± 13
)1
misc/visitors/time-complexity/time 20
1307
ns/iter (± 10
)1337
ns/iter (± 1
)0.98
misc/visitors/time-complexity/time 40
6920
ns/iter (± 58
)6865
ns/iter (± 6
)1.01
misc/visitors/time-complexity/time 60
17523
ns/iter (± 91
)17453
ns/iter (± 20
)1.00
es/full-target/es2016
249994
ns/iter (± 386
)250027
ns/iter (± 361
)1.00
es/full-target/es2017
242143
ns/iter (± 650
)243289
ns/iter (± 538
)1.00
es/full-target/es2018
230179
ns/iter (± 1065
)232280
ns/iter (± 191
)0.99
es2020_nullish_coalescing
89791
ns/iter (± 527
)90372
ns/iter (± 640
)0.99
es2020_optional_chaining
121851
ns/iter (± 895
)123712
ns/iter (± 453
)0.98
es2022_class_properties
144510
ns/iter (± 1610
)146786
ns/iter (± 336
)0.98
es2018_object_rest_spread
94009
ns/iter (± 244
)94667
ns/iter (± 231
)0.99
es2019_optional_catch_binding
83666
ns/iter (± 216
)84025
ns/iter (± 219
)1.00
es2017_async_to_generator
83943
ns/iter (± 251
)84281
ns/iter (± 148
)1.00
es2016_exponentiation
87432
ns/iter (± 486
)88642
ns/iter (± 158
)0.99
es2015_arrow
91813
ns/iter (± 469
)92341
ns/iter (± 296
)0.99
es2015_block_scoped_fn
89049
ns/iter (± 473
)90467
ns/iter (± 188
)0.98
es2015_block_scoping
165438
ns/iter (± 696
)167808
ns/iter (± 198
)0.99
This comment was automatically generated by workflow using github-action-benchmark.