1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
3
3
exports [` react-compiler-webpack (rspack) should optimize complex component 1` ] = `
4
- "function _array_like_to_array(arr, len) {
5
- if (len == null || len > arr .length ) len = arr .length ;
6
- for (var i = 0 , arr2 = new Array (len ); i < len ; i ++ )arr2 [i ] = arr [i ];
7
- return arr2 ;
8
- }
9
- function _array_with_holes(arr) {
10
- if (Array .isArray (arr )) return arr ;
11
- }
12
- function _iterable_to_array_limit(arr, i) {
13
- var _i = arr == null ? null : typeof Symbol !== \\" undefined\\ " && arr [Symbol .iterator ] || arr [\\" @@iterator\\ " ];
14
- if (_i == null ) return ;
15
- var _arr = [];
16
- var _n = true ;
17
- var _d = false ;
18
- var _s , _e ;
19
- try {
20
- for(_i = _i .call (arr ); !(_n = (_s = _i .next ()).done ); _n = true){
21
- _arr.push(_s .value );
22
- if (i && _arr .length === i ) break;
23
- }
24
- } catch (err) {
25
- _d = true ;
26
- _e = err ;
27
- } finally{
28
- try {
29
- if (!_n && _i [\\"return \\"] != null ) _i[\\" return\\ " ]();
30
- } finally {
31
- if (_d ) throw _e;
32
- }
33
- }
34
- return _arr;
35
- }
36
- function _non_iterable_rest() {
37
- throw new TypeError (\\" Invalid attempt to destructure non-iterable instance.\\\\\\\\ nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\\ " );
38
- }
39
- function _sliced_to_array(arr, i) {
40
- return _array_with_holes (arr ) || _iterable_to_array_limit (arr , i ) || _unsupported_iterable_to_array (arr , i ) || _non_iterable_rest ();
41
- }
42
- function _unsupported_iterable_to_array(o, minLen) {
43
- if (! o ) return ;
44
- if (typeof o === \\" string\\ " ) return _array_like_to_array (o , minLen );
45
- var n = Object .prototype .toString .call (o ).slice (8 , - 1 );
46
- if (n === \\" Object\\ " && o .constructor ) n = o .constructor .name ;
47
- if (n === \\" Map\\ " || n === \\" Set\\ " ) return Array .from (n );
48
- if (n === \\" Arguments\\ " || / ^ (?:Ui| I)nt(?:8| 16| 32)(?:Clamped)? Array$ / .test (n )) return _array_like_to_array (o , minLen );
49
- }
4
+ "import { jsx as _jsx , jsxs as _jsxs } from \\ "react/jsx-runtime\\ ";
50
5
import { c as _c } from \\ "react/compiler-runtime\\ ";
51
- import { useState , useRef } from \\ " react\\ " ;
6
+ import { useState , useRef } from ' react' ;
52
7
export default function Sukka() {
53
- var $ = _c (13 );
54
- var _useState = _sliced_to_array ( useState ( 0 ), 2 ), count = _useState [ 0 ] , setCount = _useState [ 1 ] ;
55
- var singletonRef = useRef (null );
8
+ const $ = _c (13 );
9
+ const [ count , setCount ] = useState ( 0 ) ;
10
+ const singletonRef = useRef (null );
56
11
if (! singletonRef .current ) singletonRef .current = new AbortController ();
57
- var t0 ;
12
+ let t0 ;
58
13
if ($ [0 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
59
- t0 = function() {
60
- return setCount (function (count_0 ) {
61
- return count_0 + 1 ;
62
- });
63
- };
14
+ t0 = ()=>setCount((count_0 )=>count_0 + 1);
64
15
$[0] = t0;
65
16
} else t0 = $ [0 ];
66
- var handleButtonClick = t0 ;
17
+ const handleButtonClick = t0 ;
67
18
if (count > 10 ) return null ;
68
- var t1 ;
19
+ let t1 ;
69
20
if ($ [1 ] !== count ) {
70
- t1 = /* #__PURE__*/ React.createElement(\\"p \\", null , \\"Count : \\" , count);
21
+ t1 = /* #__PURE__*/ _jsxs(\\"p \\", {
22
+ children : [
23
+ \\"Count : \\",
24
+ count
25
+ ]
26
+ });
71
27
$[1] = count;
72
28
$[2] = t1;
73
29
} else t1 = $ [2 ];
74
- var t2 ;
30
+ let t2 ;
75
31
if ($ [3 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
76
- t2 = /* #__PURE__*/ React .createElement (\\" button\\ " , {
77
- onClick: handleButtonClick
78
- }, \\" Increment\\ " );
32
+ t2 = /* #__PURE__*/ _jsx(\\"button \\", {
33
+ onClick : handleButtonClick ,
34
+ children : \\"Increment \\"
35
+ });
79
36
$[3] = t2;
80
37
} else t2 = $ [3 ];
81
- var t3;
38
+ let t3 ;
82
39
if ($ [4 ] !== count ) {
83
- t3 = count > 10 && /* #__PURE__*/ React .createElement (\\" p\\ " , null , \\" Count is higher than 10\\ " );
40
+ t3 = count > 10 && /* #__PURE__*/ _jsx(\\"p \\", {
41
+ children : \\"Count is higher than 10\\"
42
+ });
84
43
$[4] = count;
85
44
$[5] = t3;
86
45
} else t3 = $ [5 ];
87
- var t4 = count > 0;
88
- var t5;
46
+ const t4 = count > 0 ;
47
+ let t5 ;
89
48
if ($ [6 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
90
- t5 = function () {
91
- return setCount (0 );
92
- };
49
+ t5 = ()=>setCount(0);
93
50
$[6] = t5;
94
51
} else t5 = $ [6 ];
95
- var t6;
52
+ let t6 ;
96
53
if ($ [7 ] !== t4 ) {
97
- t6 = /* #__PURE__*/ React . createElement (\\" button\\ " , {
54
+ t6 = /* #__PURE__*/ _jsx (\\"button \\", {
98
55
disabled : t4 ,
99
- onClick: t5
100
- }, \\" Reset Count\\ " );
56
+ onClick : t5 ,
57
+ children : \\"Reset Count \\"
58
+ });
101
59
$[7] = t4;
102
60
$[8] = t6;
103
61
} else t6 = $ [8 ];
104
- var t7;
62
+ let t7 ;
105
63
if ($ [9 ] !== t1 || $ [10 ] !== t3 || $ [11 ] !== t6 ) {
106
- t7 = /* #__PURE__*/ React .createElement (\\" div\\ " , null , t1 , t2 , t3 , t6 );
64
+ t7 = /* #__PURE__*/ _jsxs(\\"div \\", {
65
+ children : [
66
+ t1 ,
67
+ t2 ,
68
+ t3 ,
69
+ t6
70
+ ]
71
+ });
107
72
$[9] = t1;
108
73
$[10] = t3;
109
74
$[11] = t6;
@@ -115,10 +80,11 @@ export default function Sukka() {
115
80
` ;
116
81
117
82
exports [` react-compiler-webpack (rspack) should work 1` ] = `
118
- "import { c as _c } from \\ "react/compiler-runtime\\ ";
83
+ "import { jsx as _jsx } from \\ "react/jsx-runtime\\ ";
84
+ import { c as _c } from \\ "react/compiler-runtime\\ ";
119
85
export default function Example() {
120
- var $ = _c (2 );
121
- var t0 ;
86
+ const $ = _c (2 );
87
+ let t0 ;
122
88
if ($ [0 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
123
89
t0 = [
124
90
1,
@@ -128,14 +94,14 @@ export default function Example() {
128
94
];
129
95
$[0] = t0;
130
96
} else t0 = $ [0 ];
131
- var value = t0 ;
132
- var t1 ;
97
+ const value = t0 ;
98
+ let t1 ;
133
99
if ($ [1 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
134
- t1 = /* #__PURE__*/ React.createElement (\\"div \\", null , value . map ( function ( i ) {
135
- return /* #__PURE__*/ React . createElement (\\" p\\ " , {
136
- key : i
137
- }, i );
138
- })) ;
100
+ t1 = /* #__PURE__*/ _jsx (\\"div \\", {
101
+ children : value . map (( i ) = > /* #__PURE__*/ _jsx (\\" p\\ " , {
102
+ children : i
103
+ }, i ))
104
+ });
139
105
$[1] = t1;
140
106
} else t1 = $ [1 ];
141
107
return t1 ;
@@ -144,10 +110,11 @@ export default function Example() {
144
110
` ;
145
111
146
112
exports [` react-compiler-webpack (rspack) should work with tsx 1` ] = `
147
- "import { c as _c } from \\ "react/compiler-runtime\\ ";
113
+ "import { jsx as _jsx } from \\ "react/jsx-runtime\\ ";
114
+ import { c as _c } from \\ "react/compiler-runtime\\ ";
148
115
export default function Example() {
149
- var $ = _c (2 );
150
- var t0 ;
116
+ const $ = _c (2 );
117
+ let t0 ;
151
118
if ($ [0 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
152
119
t0 = [
153
120
1,
@@ -157,21 +124,21 @@ export default function Example() {
157
124
];
158
125
$[0] = t0;
159
126
} else t0 = $ [0 ];
160
- var value = t0 ;
161
- var t1 ;
127
+ const value = t0 ;
128
+ let t1 ;
162
129
if ($ [1 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
163
- t1 = /* #__PURE__*/ React.createElement (\\"div \\", null , value . map ( function ( i ) {
164
- return /* #__PURE__*/ React . createElement (\\" p\\ " , {
165
- key : i
166
- }, i );
167
- })) ;
130
+ t1 = /* #__PURE__*/ _jsx (\\"div \\", {
131
+ children : value . map (( i ) = > /* #__PURE__*/ _jsx (\\" p\\ " , {
132
+ children : i
133
+ }, i ))
134
+ });
168
135
$[1] = t1;
169
136
} else t1 = $ [1 ];
170
137
return t1 ;
171
138
}
172
- export var AnotherExmaple = function() {
173
- var $ = _c (2 );
174
- var t0 ;
139
+ export const AnotherExmaple = ()=> {
140
+ const $ = _c (2 );
141
+ let t0 ;
175
142
if ($ [0 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
176
143
t0 = [
177
144
1,
@@ -181,14 +148,14 @@ export var AnotherExmaple = function() {
181
148
];
182
149
$[0] = t0;
183
150
} else t0 = $ [0 ];
184
- var value = t0 ;
185
- var t1 ;
151
+ const value = t0 ;
152
+ let t1 ;
186
153
if ($ [1 ] === Symbol .for (\\" react.memo_cache_sentinel\\ " )) {
187
- t1 = /* #__PURE__*/ React.createElement (\\"div \\", null , value . map ( function ( i ) {
188
- return /* #__PURE__*/ React . createElement (\\" p\\ " , {
189
- key : i
190
- }, i );
191
- })) ;
154
+ t1 = /* #__PURE__*/ _jsx (\\"div \\", {
155
+ children : value . map (( i ) = > /* #__PURE__*/ _jsx (\\" p\\ " , {
156
+ children : i
157
+ }, i ))
158
+ });
192
159
$[1] = t1;
193
160
} else t1 = $ [1 ];
194
161
return t1 ;
0 commit comments