Skip to content

Commit 9e5f68d

Browse files
committed
fix(rust): prep tests for better noop
note: reg_ctx_name_segments output is wrong, should include the server qrl
1 parent 11bcf73 commit 9e5f68d

6 files changed

+38
-42
lines changed

packages/qwik/src/optimizer/core/src/snapshots/qwik_core__test__example_drop_side_effects.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
source: packages/qwik/src/optimizer/core/src/test.rs
3-
assertion_line: 821
3+
assertion_line: 822
44
expression: output
5-
snapshot_kind: text
65
---
76
==INPUT==
87

packages/qwik/src/optimizer/core/src/snapshots/qwik_core__test__example_noop_dev_mode.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
source: packages/qwik/src/optimizer/core/src/test.rs
3-
assertion_line: 3814
3+
assertion_line: 3816
44
expression: output
5-
snapshot_kind: text
65
---
76
==INPUT==
87

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
source: packages/qwik/src/optimizer/core/src/test.rs
3-
assertion_line: 865
3+
assertion_line: 866
44
expression: output
5-
snapshot_kind: text
65
---
76
==INPUT==
87

@@ -13,7 +12,7 @@ export const Works = component$((props) => {
1312
const text = 'hola';
1413
return (
1514
<>
16-
<div onClick$={server$(() => console.log('in server', text))}></div>
15+
<div onClick$={() => server$(() => console.log('in server', text))}></div>
1716
<div onClick$={() => foo()}></div>
1817
</>
1918
);
@@ -23,25 +22,23 @@ export const Works = component$((props) => {
2322

2423
import "./foo";
2524
import { componentQrl } from "@qwik.dev/core";
26-
import { serverQrl } from "@qwik.dev/core";
27-
import { _regSymbol } from "@qwik.dev/core";
2825
import { inlinedQrl } from "@qwik.dev/core";
29-
import { _jsxSorted } from "@qwik.dev/core";
3026
import { _noopQrl } from "@qwik.dev/core";
27+
import { _jsxSorted } from "@qwik.dev/core";
3128
import { Fragment as _Fragment } from "@qwik.dev/core/jsx-runtime";
3229
export const Works = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl((props)=>{
3330
return /*#__PURE__*/ _jsxSorted(_Fragment, null, null, [
34-
/*#__PURE__*/ _jsxSorted("div", {
35-
onClick$: serverQrl(/*#__PURE__*/ inlinedQrl(/*#__PURE__*/ _regSymbol(()=>console.log('in server', 'hola'), "gcSPFNpGYgg"), "Works_component_Fragment_div_onClick_server_gcSPFNpGYgg"))
36-
}, null, null, 2, null),
3731
/*#__PURE__*/ _jsxSorted("div", null, {
3832
onClick$: /*#__PURE__*/ _noopQrl("Works_component_Fragment_div_onClick_nO4DPVZWP7g")
33+
}, null, 3, null),
34+
/*#__PURE__*/ _jsxSorted("div", null, {
35+
onClick$: /*#__PURE__*/ _noopQrl("Works_component_Fragment_div_onClick_1_GlJs0t0HdXk")
3936
}, null, 3, null)
40-
], 1, "u6_0");
37+
], 3, "u6_0");
4138
}, "Works_component_t45qL4vNGv0"));
4239

4340

44-
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;;;;AAGA,OAAO,MAAM,sBAAQ,sCAAW,CAAC;IAEhC,qBACC;sBACA,WAAC;YAAI,UAAU,4DAAQ,IAAM,QAAQ,GAAG,CAAC,aAH7B;;sBAIZ,WAAC;YAAI,QAAQ;;;AAGf,mCAAG\"}")
41+
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;;AAGA,OAAO,MAAM,sBAAQ,sCAAW,CAAC;IAEhC,qBACC;sBACA,WAAC;YAAI,QAAQ;;sBACb,WAAC;YAAI,QAAQ;;;AAGf,mCAAG\"}")
4542
== DIAGNOSTICS ==
4643

4744
[]

packages/qwik/src/optimizer/core/src/snapshots/qwik_core__test__example_strip_client_code.snap

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
source: packages/qwik/src/optimizer/core/src/test.rs
3-
assertion_line: 1929
3+
assertion_line: 1930
44
expression: output
5-
snapshot_kind: text
65
---
76
==INPUT==
87

@@ -28,6 +27,7 @@ export const Parent = component$(() => {
2827

2928
useTask$(() => {
3029
// Code
30+
runSomething();
3131
});
3232

3333
return (
@@ -66,7 +66,8 @@ export const Parent = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(()=>{
6666
state
6767
]));
6868
useTaskQrl(/*#__PURE__*/ inlinedQrl(()=>{
69-
// Code
69+
// Code
70+
runSomething();
7071
}, "Parent_component_useTask_ngmvcygWux8"));
7172
return /*#__PURE__*/ _jsxSorted("div", null, {
7273
shouldRemove$: /*#__PURE__*/ _noopQrl("Parent_component_div_shouldRemove_EBj69wTX1do", [
@@ -90,7 +91,7 @@ export const Parent = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(()=>{
9091
}, "Parent_component_t6Wy3C0Q0XM"));
9192

9293

93-
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/components/component.tsx\"],\"names\":[],\"mappings\":\";;;;;;;;;;AACA,SAAsC,QAAQ,QAAkB,iBAAiB;AAQjF,OAAO,MAAM,uBAAS,sCAAW;IAChC,MAAM,QAAQ,SAAS;QACtB,MAAM;IACP;IAEA,qBAAqB;IACrB;;;IAKA,oCAAS;IACR,OAAO;IACR;IAEA,qBACC,WAAC;QACA,aAAa;;;QACb,QAAQ;;;;sBAER,WAAC;YACA,QAAQ,2BAAE,IAAM,QAAQ,GAAG,CAAC;YAC5B,OAAO,2BAAE;;uBAAM,MAAM,IAAI;;;;;kBAEzB;;AAGJ,oCAAG\"}")
94+
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/components/component.tsx\"],\"names\":[],\"mappings\":\";;;;;;;;;;AACA,SAAsC,QAAQ,QAAkB,iBAAiB;AAQjF,OAAO,MAAM,uBAAS,sCAAW;IAChC,MAAM,QAAQ,SAAS;QACtB,MAAM;IACP;IAEA,qBAAqB;IACrB;;;IAKA,oCAAS;QACR,OAAO;QACP;IACD;IAEA,qBACC,WAAC;QACA,aAAa;;;QACb,QAAQ;;;;sBAER,WAAC;YACA,QAAQ,2BAAE,IAAM,QAAQ,GAAG,CAAC;YAC5B,OAAO,2BAAE;;uBAAM,MAAM,IAAI;;;;;kBAEzB;;AAGJ,oCAAG\"}")
9495
== DIAGNOSTICS ==
9596

9697
[]

packages/qwik/src/optimizer/core/src/snapshots/qwik_core__test__example_strip_server_code.snap

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
source: packages/qwik/src/optimizer/core/src/test.rs
3-
assertion_line: 1822
3+
assertion_line: 1823
44
expression: output
5-
snapshot_kind: text
65
---
76
==INPUT==
87

@@ -28,18 +27,18 @@ export const Parent = component$(() => {
2827
serverStuff$(async () => {
2928
// should be removed too
3029
const a = $(() => {
31-
// from $(), should not be removed
30+
dontRemoveThisDollar();
3231
});
3332
const b = client$(() => {
34-
// from clien$(), should not be removed
33+
dontRemoveThisClient();
3534
});
3635
return [a,b];
3736
})
3837

3938
serverLoader$(handler);
4039

4140
useTask$(() => {
42-
// Code
41+
runSomething();
4342
});
4443

4544
return (
@@ -97,11 +96,11 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
9796
============================= test.tsx_Parent_component_serverStuff_a_2ca3HLDC7yc.js (ENTRY POINT)==
9897

9998
export const s_2ca3HLDC7yc = ()=>{
100-
// from $(), should not be removed
99+
dontRemoveThisDollar();
101100
};
102101

103102

104-
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"6BAqBc;AACX,kCAAkC;AACnC\"}")
103+
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"6BAqBc;IACX;AACD\"}")
105104
/*
106105
{
107106
"origin": "test.tsx",
@@ -118,18 +117,18 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
118117
"captures": false,
119118
"loc": [
120119
538,
121-
587
120+
576
122121
]
123122
}
124123
*/
125124
============================= test.tsx_Parent_component_serverStuff_b_client_v9qawr2Inkk.js (ENTRY POINT)==
126125

127126
export const s_v9qawr2Inkk = ()=>{
128-
// from clien$(), should not be removed
127+
dontRemoveThisClient();
129128
};
130129

131130

132-
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"6BAwBoB;AACjB,uCAAuC;AACxC\"}")
131+
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"6BAwBoB;IACjB;AACD\"}")
133132
/*
134133
{
135134
"origin": "test.tsx",
@@ -145,8 +144,8 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
145144
"ctxName": "client$",
146145
"captures": false,
147146
"loc": [
148-
610,
149-
664
147+
599,
148+
637
150149
]
151150
}
152151
*/
@@ -197,7 +196,7 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
197196
"captures": false,
198197
"loc": [
199198
279,
200-
835
199+
816
201200
]
202201
}
203202
*/
@@ -222,19 +221,19 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
222221
"ctxName": "onClick$",
223222
"captures": false,
224223
"loc": [
225-
775,
226-
802
224+
756,
225+
783
227226
]
228227
}
229228
*/
230229
============================= test.tsx_Parent_component_useTask_1_P8oRQhHsurk.js (ENTRY POINT)==
231230

232231
export const s_P8oRQhHsurk = ()=>{
233-
// Code
232+
runSomething();
234233
};
235234

236235

237-
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"6BAgCU;AACR,OAAO;AACR\"}")
236+
Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"6BAgCU;IACR;AACD\"}")
238237
/*
239238
{
240239
"origin": "test.tsx",
@@ -250,8 +249,8 @@ Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"ma
250249
"ctxName": "useTask$",
251250
"captures": false,
252251
"loc": [
253-
724,
254-
744
252+
697,
253+
725
255254
]
256255
}
257256
*/

packages/qwik/src/optimizer/core/src/test.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ export const Works = component$((props) => {
871871
const text = 'hola';
872872
return (
873873
<>
874-
<div onClick$={server$(() => console.log('in server', text))}></div>
874+
<div onClick$={() => server$(() => console.log('in server', text))}></div>
875875
<div onClick$={() => foo()}></div>
876876
</>
877877
);
@@ -1843,18 +1843,18 @@ export const Parent = component$(() => {
18431843
serverStuff$(async () => {
18441844
// should be removed too
18451845
const a = $(() => {
1846-
// from $(), should not be removed
1846+
dontRemoveThisDollar();
18471847
});
18481848
const b = client$(() => {
1849-
// from clien$(), should not be removed
1849+
dontRemoveThisClient();
18501850
});
18511851
return [a,b];
18521852
})
18531853
18541854
serverLoader$(handler);
18551855
18561856
useTask$(() => {
1857-
// Code
1857+
runSomething();
18581858
});
18591859
18601860
return (
@@ -1950,6 +1950,7 @@ export const Parent = component$(() => {
19501950
19511951
useTask$(() => {
19521952
// Code
1953+
runSomething();
19531954
});
19541955
19551956
return (

0 commit comments

Comments
 (0)