rwsdk 1.0.0-alpha.2 → 1.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/e2e/browser.d.mts +10 -0
- package/dist/lib/e2e/browser.mjs +124 -0
- package/dist/lib/e2e/dev.d.mts +8 -0
- package/dist/lib/e2e/dev.mjs +242 -0
- package/dist/lib/e2e/environment.d.mts +14 -0
- package/dist/lib/e2e/environment.mjs +266 -0
- package/dist/lib/e2e/index.d.mts +8 -0
- package/dist/lib/e2e/index.mjs +8 -0
- package/dist/lib/e2e/poll.d.mts +8 -0
- package/dist/lib/e2e/poll.mjs +31 -0
- package/dist/lib/e2e/release.d.mts +56 -0
- package/dist/lib/e2e/release.mjs +559 -0
- package/dist/lib/e2e/retry.d.mts +4 -0
- package/dist/lib/e2e/retry.mjs +16 -0
- package/dist/lib/e2e/setup.d.mts +2 -0
- package/dist/lib/e2e/setup.mjs +1 -0
- package/dist/lib/e2e/tarball.d.mts +14 -0
- package/dist/lib/e2e/tarball.mjs +99 -0
- package/dist/lib/e2e/testHarness.d.mts +132 -0
- package/dist/lib/e2e/testHarness.mjs +437 -0
- package/dist/lib/e2e/types.d.mts +32 -0
- package/dist/lib/getShortName.mjs +6 -1
- package/dist/lib/getShortName.test.d.mts +1 -0
- package/dist/lib/getShortName.test.mjs +25 -0
- package/dist/lib/hasPkgScript.d.mts +4 -1
- package/dist/lib/hasPkgScript.mjs +9 -6
- package/dist/lib/hasPkgScript.test.d.mts +1 -0
- package/dist/lib/hasPkgScript.test.mjs +33 -0
- package/dist/lib/jsonUtils.mjs +3 -0
- package/dist/lib/jsonUtils.test.d.mts +1 -0
- package/dist/lib/jsonUtils.test.mjs +90 -0
- package/dist/lib/normalizeModulePath.d.mts +5 -0
- package/dist/lib/normalizeModulePath.mjs +1 -1
- package/dist/lib/normalizeModulePath.test.d.mts +1 -0
- package/dist/lib/{normalizeModulePath.test.js → normalizeModulePath.test.mjs} +20 -1
- package/dist/lib/smokeTests/browser.mjs +3 -94
- package/dist/lib/smokeTests/development.mjs +2 -223
- package/dist/lib/smokeTests/environment.d.mts +4 -11
- package/dist/lib/smokeTests/environment.mjs +10 -158
- package/dist/lib/smokeTests/release.d.mts +2 -49
- package/dist/lib/smokeTests/release.mjs +3 -503
- package/dist/llms/rules/middleware.d.ts +1 -1
- package/dist/llms/rules/middleware.js +4 -4
- package/dist/runtime/entries/worker.d.ts +0 -1
- package/dist/runtime/entries/worker.js +0 -1
- package/dist/runtime/lib/auth/session.d.ts +2 -2
- package/dist/runtime/lib/auth/session.js +4 -4
- package/dist/runtime/lib/memoizeOnId.test.d.ts +1 -0
- package/dist/runtime/lib/memoizeOnId.test.js +49 -0
- package/dist/runtime/lib/realtime/protocol.test.d.ts +1 -0
- package/dist/runtime/lib/realtime/protocol.test.js +107 -0
- package/dist/runtime/lib/realtime/shared.test.d.ts +1 -0
- package/dist/runtime/lib/realtime/shared.test.js +18 -0
- package/dist/runtime/lib/realtime/validateUpgradeRequest.test.d.ts +1 -0
- package/dist/runtime/lib/realtime/validateUpgradeRequest.test.js +66 -0
- package/dist/runtime/lib/realtime/worker.d.ts +1 -1
- package/dist/runtime/lib/router.js +40 -22
- package/dist/runtime/lib/router.test.js +590 -2
- package/dist/runtime/lib/rwContext.d.ts +22 -0
- package/dist/runtime/lib/rwContext.js +1 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.d.ts +18 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.js +143 -0
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.d.ts +2 -1
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.js +6 -6
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.test.d.ts +1 -0
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.test.js +49 -0
- package/dist/runtime/register/worker.d.ts +1 -1
- package/dist/runtime/register/worker.js +33 -21
- package/dist/runtime/render/assembleDocument.d.ts +6 -0
- package/dist/runtime/render/assembleDocument.js +22 -0
- package/dist/runtime/render/createThenableFromReadableStream.d.ts +1 -0
- package/dist/runtime/render/createThenableFromReadableStream.js +9 -0
- package/dist/runtime/render/normalizeActionResult.d.ts +1 -0
- package/dist/runtime/render/normalizeActionResult.js +43 -0
- package/dist/runtime/render/preloads.d.ts +2 -2
- package/dist/runtime/render/preloads.js +2 -3
- package/dist/runtime/render/{renderRscThenableToHtmlStream.d.ts → renderDocumentHtmlStream.d.ts} +3 -3
- package/dist/runtime/render/renderDocumentHtmlStream.js +39 -0
- package/dist/runtime/render/renderHtmlStream.d.ts +7 -0
- package/dist/runtime/render/renderHtmlStream.js +31 -0
- package/dist/runtime/render/renderToRscStream.d.ts +5 -3
- package/dist/runtime/render/renderToRscStream.js +12 -41
- package/dist/runtime/render/renderToStream.d.ts +2 -1
- package/dist/runtime/render/renderToStream.js +15 -8
- package/dist/runtime/render/stylesheets.d.ts +2 -2
- package/dist/runtime/render/stylesheets.js +2 -3
- package/dist/runtime/requestInfo/types.d.ts +0 -2
- package/dist/runtime/requestInfo/worker.js +1 -9
- package/dist/runtime/ssrBridge.d.ts +2 -1
- package/dist/runtime/ssrBridge.js +2 -1
- package/dist/runtime/worker.d.ts +1 -0
- package/dist/runtime/worker.js +11 -14
- package/dist/scripts/debug-sync.mjs +102 -133
- package/dist/vite/buildApp.d.mts +2 -1
- package/dist/vite/buildApp.mjs +9 -5
- package/dist/vite/checkIsUsingPrisma.d.mts +4 -0
- package/dist/vite/checkIsUsingPrisma.mjs +2 -2
- package/dist/vite/checkIsUsingPrisma.test.d.mts +1 -0
- package/dist/vite/checkIsUsingPrisma.test.mjs +30 -0
- package/dist/vite/configPlugin.mjs +54 -14
- package/dist/vite/createDirectiveLookupPlugin.d.mts +9 -0
- package/dist/vite/createDirectiveLookupPlugin.mjs +33 -29
- package/dist/vite/createDirectiveLookupPlugin.test.d.mts +1 -0
- package/dist/vite/createDirectiveLookupPlugin.test.mjs +40 -0
- package/dist/vite/directiveModulesDevPlugin.d.mts +4 -1
- package/dist/vite/directiveModulesDevPlugin.mjs +6 -5
- package/dist/vite/directiveModulesDevPlugin.test.d.mts +1 -0
- package/dist/vite/directiveModulesDevPlugin.test.mjs +59 -0
- package/dist/vite/directivesPlugin.d.mts +1 -0
- package/dist/vite/directivesPlugin.mjs +1 -1
- package/dist/vite/directivesPlugin.test.d.mts +1 -0
- package/dist/vite/directivesPlugin.test.mjs +24 -0
- package/dist/vite/ensureAliasArray.test.d.mts +1 -0
- package/dist/vite/ensureAliasArray.test.mjs +71 -0
- package/dist/vite/findSpecifiers.mjs +2 -1
- package/dist/vite/findSpecifiers.test.d.mts +1 -0
- package/dist/vite/findSpecifiers.test.mjs +202 -0
- package/dist/vite/findSsrSpecifiers.test.d.mts +1 -0
- package/dist/vite/findSsrSpecifiers.test.mjs +99 -0
- package/dist/vite/hasDirective.d.mts +6 -3
- package/dist/vite/hasDirective.mjs +43 -27
- package/dist/vite/hasDirective.test.d.mts +1 -0
- package/dist/vite/hasDirective.test.mjs +107 -0
- package/dist/vite/isJsFile.test.d.mts +1 -0
- package/dist/vite/isJsFile.test.mjs +38 -0
- package/dist/vite/{reactConditionsResolverPlugin.d.mts → knownDepsResolverPlugin.d.mts} +2 -2
- package/dist/vite/{reactConditionsResolverPlugin.mjs → knownDepsResolverPlugin.mjs} +28 -23
- package/dist/vite/linkerPlugin.d.mts +8 -0
- package/dist/vite/linkerPlugin.mjs +30 -22
- package/dist/vite/linkerPlugin.test.d.mts +1 -0
- package/dist/vite/linkerPlugin.test.mjs +41 -0
- package/dist/vite/miniflareHMRPlugin.d.mts +5 -0
- package/dist/vite/miniflareHMRPlugin.mjs +2 -2
- package/dist/vite/miniflareHMRPlugin.test.d.mts +1 -0
- package/dist/vite/miniflareHMRPlugin.test.mjs +42 -0
- package/dist/vite/redwoodPlugin.d.mts +9 -0
- package/dist/vite/redwoodPlugin.mjs +29 -5
- package/dist/vite/redwoodPlugin.test.d.mts +1 -0
- package/dist/vite/redwoodPlugin.test.mjs +34 -0
- package/dist/vite/resolveForcedPaths.d.mts +4 -0
- package/dist/vite/resolveForcedPaths.mjs +9 -0
- package/dist/vite/runDirectivesScan.d.mts +22 -1
- package/dist/vite/runDirectivesScan.mjs +105 -58
- package/dist/vite/runDirectivesScan.test.d.mts +1 -0
- package/dist/vite/runDirectivesScan.test.mjs +73 -0
- package/dist/vite/ssrBridgePlugin.mjs +8 -1
- package/dist/vite/transformClientComponents.mjs +6 -4
- package/dist/vite/transformClientComponents.test.mjs +116 -58
- package/dist/vite/transformServerFunctions.d.mts +1 -1
- package/dist/vite/transformServerFunctions.mjs +1 -1
- package/dist/vite/transformServerFunctions.test.mjs +3 -3
- package/package.json +56 -47
- package/dist/runtime/imports/resolveSSRValue.d.ts +0 -1
- package/dist/runtime/imports/resolveSSRValue.js +0 -8
- package/dist/runtime/render/renderRscThenableToHtmlStream.js +0 -54
- package/dist/runtime/render/transformRscToHtmlStream.d.ts +0 -8
- package/dist/runtime/render/transformRscToHtmlStream.js +0 -19
- /package/dist/lib/{normalizeModulePath.test.d.ts → e2e/types.mjs} +0 -0
|
@@ -13,8 +13,10 @@ describe("transformClientComponents", () => {
|
|
|
13
13
|
export const Component = () => {
|
|
14
14
|
return jsx('div', { children: 'Hello' });
|
|
15
15
|
}
|
|
16
|
-
`)) ?? "").toEqual(`import {
|
|
17
|
-
|
|
16
|
+
`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
17
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
18
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
19
|
+
const Component = registerClientReference(SSRModule, "/test/file.tsx", "Component");
|
|
18
20
|
export { Component };
|
|
19
21
|
`);
|
|
20
22
|
});
|
|
@@ -24,8 +26,10 @@ export { Component };
|
|
|
24
26
|
export const Component = async () => {
|
|
25
27
|
return jsx('div', { children: 'Hello' });
|
|
26
28
|
}
|
|
27
|
-
`)) ?? "").toEqual(`import {
|
|
28
|
-
|
|
29
|
+
`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
30
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
31
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
32
|
+
const Component = registerClientReference(SSRModule, "/test/file.tsx", "Component");
|
|
29
33
|
export { Component };
|
|
30
34
|
`);
|
|
31
35
|
});
|
|
@@ -34,8 +38,10 @@ export { Component };
|
|
|
34
38
|
|
|
35
39
|
export function Component() {
|
|
36
40
|
return jsx('div', { children: 'Hello' });
|
|
37
|
-
}`)) ?? "").toEqual(`import {
|
|
38
|
-
|
|
41
|
+
}`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
42
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
43
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
44
|
+
const Component = registerClientReference(SSRModule, "/test/file.tsx", "Component");
|
|
39
45
|
export { Component };
|
|
40
46
|
`);
|
|
41
47
|
});
|
|
@@ -44,8 +50,10 @@ export { Component };
|
|
|
44
50
|
|
|
45
51
|
export default () => {
|
|
46
52
|
return jsx('div', { children: 'Hello' });
|
|
47
|
-
}`)) ?? "").toEqual(`import {
|
|
48
|
-
|
|
53
|
+
}`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
54
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
55
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
56
|
+
export default registerClientReference(SSRModule, "/test/file.tsx", "default");
|
|
49
57
|
`);
|
|
50
58
|
});
|
|
51
59
|
it("transforms default export function declaration component", async () => {
|
|
@@ -53,8 +61,10 @@ export default registerClientReference("/test/file.tsx", "default");
|
|
|
53
61
|
|
|
54
62
|
export default function Component({ prop1, prop2 }) {
|
|
55
63
|
return jsx('div', { children: 'Hello' });
|
|
56
|
-
}`)) ?? "").toEqual(`import {
|
|
57
|
-
|
|
64
|
+
}`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
65
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
66
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
67
|
+
export default registerClientReference(SSRModule, "/test/file.tsx", "default");
|
|
58
68
|
`);
|
|
59
69
|
});
|
|
60
70
|
it("transforms mixed export styles (inline, grouped, and default)", async () => {
|
|
@@ -81,13 +91,15 @@ export default function Main() {
|
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
export { Second, Third }
|
|
84
|
-
export { Fourth as AnotherName }`)) ?? "").toEqual(`import {
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
94
|
+
export { Fourth as AnotherName }`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
95
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
96
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
97
|
+
const First = registerClientReference(SSRModule, "/test/file.tsx", "First");
|
|
98
|
+
const Second = registerClientReference(SSRModule, "/test/file.tsx", "Second");
|
|
99
|
+
const Third = registerClientReference(SSRModule, "/test/file.tsx", "Third");
|
|
100
|
+
const Fourth_AnotherName = registerClientReference(SSRModule, "/test/file.tsx", "AnotherName");
|
|
89
101
|
export { First, Second, Third, Fourth_AnotherName as AnotherName };
|
|
90
|
-
export default registerClientReference("/test/file.tsx", "default");
|
|
102
|
+
export default registerClientReference(SSRModule, "/test/file.tsx", "default");
|
|
91
103
|
`);
|
|
92
104
|
});
|
|
93
105
|
it("transforms function declaration that is exported default separately", async () => {
|
|
@@ -98,8 +110,10 @@ function Component({ prop1, prop2 }) {
|
|
|
98
110
|
return jsx('div', { children: 'Hello' });
|
|
99
111
|
}
|
|
100
112
|
|
|
101
|
-
export default Component;`)) ?? "").toEqual(`import {
|
|
102
|
-
|
|
113
|
+
export default Component;`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
114
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
115
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
116
|
+
export default registerClientReference(SSRModule, "/test/file.tsx", "default");
|
|
103
117
|
`);
|
|
104
118
|
});
|
|
105
119
|
it("Works in dev", async () => {
|
|
@@ -183,8 +197,10 @@ export function Chat() {
|
|
|
183
197
|
columnNumber: 5
|
|
184
198
|
}, this);
|
|
185
199
|
}
|
|
186
|
-
`)) ?? "").toEqual(`import {
|
|
187
|
-
|
|
200
|
+
`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
201
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
202
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
203
|
+
const Chat = registerClientReference(SSRModule, "/test/file.tsx", "Chat");
|
|
188
204
|
export { Chat };
|
|
189
205
|
`);
|
|
190
206
|
});
|
|
@@ -198,8 +214,10 @@ const MyComponent = () => {
|
|
|
198
214
|
return jsx('div', { children: 'Hello' });
|
|
199
215
|
}
|
|
200
216
|
|
|
201
|
-
export { MyComponent as CustomName }`)) ?? "").toEqual(`import {
|
|
202
|
-
|
|
217
|
+
export { MyComponent as CustomName }`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
218
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
219
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
220
|
+
const MyComponent_CustomName = registerClientReference(SSRModule, "/test/file.tsx", "CustomName");
|
|
203
221
|
export { MyComponent_CustomName as CustomName };
|
|
204
222
|
`);
|
|
205
223
|
});
|
|
@@ -210,10 +228,12 @@ const First = () => jsx('div', { children: 'First' });
|
|
|
210
228
|
const Second = () => jsx('div', { children: 'Second' });
|
|
211
229
|
const Third = () => jsx('div', { children: 'Third' });
|
|
212
230
|
|
|
213
|
-
export { First, Second, Third }`)) ?? "").toEqual(`import {
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
const
|
|
231
|
+
export { First, Second, Third }`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
232
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
233
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
234
|
+
const First = registerClientReference(SSRModule, "/test/file.tsx", "First");
|
|
235
|
+
const Second = registerClientReference(SSRModule, "/test/file.tsx", "Second");
|
|
236
|
+
const Third = registerClientReference(SSRModule, "/test/file.tsx", "Third");
|
|
217
237
|
export { First, Second, Third };
|
|
218
238
|
`);
|
|
219
239
|
});
|
|
@@ -224,10 +244,12 @@ const Component = () => jsx('div', {});
|
|
|
224
244
|
const data = { value: 42 };
|
|
225
245
|
const helper = () => console.log('helper');
|
|
226
246
|
|
|
227
|
-
export { Component, data, helper }`)) ?? "").toEqual(`import {
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
const
|
|
247
|
+
export { Component, data, helper }`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
248
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
249
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
250
|
+
const Component = registerClientReference(SSRModule, "/test/file.tsx", "Component");
|
|
251
|
+
const data = registerClientReference(SSRModule, "/test/file.tsx", "data");
|
|
252
|
+
const helper = registerClientReference(SSRModule, "/test/file.tsx", "helper");
|
|
231
253
|
export { Component, data, helper };
|
|
232
254
|
`);
|
|
233
255
|
});
|
|
@@ -239,9 +261,11 @@ export const Slot = () => {
|
|
|
239
261
|
}
|
|
240
262
|
|
|
241
263
|
export { Slot, Slot as Root }
|
|
242
|
-
`)) ?? "").toEqual(`import {
|
|
243
|
-
|
|
244
|
-
const
|
|
264
|
+
`)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
265
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
266
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
267
|
+
const Slot = registerClientReference(SSRModule, "/test/file.tsx", "Slot");
|
|
268
|
+
const Slot_Root = registerClientReference(SSRModule, "/test/file.tsx", "Root");
|
|
245
269
|
export { Slot, Slot_Root as Root };
|
|
246
270
|
`);
|
|
247
271
|
});
|
|
@@ -274,31 +298,33 @@ function SidebarMenuSub() { return jsx("div", {}); }
|
|
|
274
298
|
function SidebarMenuSubItem() { return jsx("div", {}); }
|
|
275
299
|
function SidebarMenuSubButton() { return jsx("div", {}); }
|
|
276
300
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };`;
|
|
277
|
-
expect((await transform(code)) ?? "").toEqual(`import {
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
const
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
const
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
const
|
|
301
|
+
expect((await transform(code)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
302
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
303
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
304
|
+
const Sidebar = registerClientReference(SSRModule, "/test/file.tsx", "Sidebar");
|
|
305
|
+
const SidebarContent = registerClientReference(SSRModule, "/test/file.tsx", "SidebarContent");
|
|
306
|
+
const SidebarFooter = registerClientReference(SSRModule, "/test/file.tsx", "SidebarFooter");
|
|
307
|
+
const SidebarGroup = registerClientReference(SSRModule, "/test/file.tsx", "SidebarGroup");
|
|
308
|
+
const SidebarGroupAction = registerClientReference(SSRModule, "/test/file.tsx", "SidebarGroupAction");
|
|
309
|
+
const SidebarGroupContent = registerClientReference(SSRModule, "/test/file.tsx", "SidebarGroupContent");
|
|
310
|
+
const SidebarGroupLabel = registerClientReference(SSRModule, "/test/file.tsx", "SidebarGroupLabel");
|
|
311
|
+
const SidebarHeader = registerClientReference(SSRModule, "/test/file.tsx", "SidebarHeader");
|
|
312
|
+
const SidebarInput = registerClientReference(SSRModule, "/test/file.tsx", "SidebarInput");
|
|
313
|
+
const SidebarInset = registerClientReference(SSRModule, "/test/file.tsx", "SidebarInset");
|
|
314
|
+
const SidebarMenu = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenu");
|
|
315
|
+
const SidebarMenuAction = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuAction");
|
|
316
|
+
const SidebarMenuBadge = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuBadge");
|
|
317
|
+
const SidebarMenuButton = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuButton");
|
|
318
|
+
const SidebarMenuItem = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuItem");
|
|
319
|
+
const SidebarMenuSkeleton = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuSkeleton");
|
|
320
|
+
const SidebarMenuSub = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuSub");
|
|
321
|
+
const SidebarMenuSubButton = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuSubButton");
|
|
322
|
+
const SidebarMenuSubItem = registerClientReference(SSRModule, "/test/file.tsx", "SidebarMenuSubItem");
|
|
323
|
+
const SidebarProvider = registerClientReference(SSRModule, "/test/file.tsx", "SidebarProvider");
|
|
324
|
+
const SidebarRail = registerClientReference(SSRModule, "/test/file.tsx", "SidebarRail");
|
|
325
|
+
const SidebarSeparator = registerClientReference(SSRModule, "/test/file.tsx", "SidebarSeparator");
|
|
326
|
+
const SidebarTrigger = registerClientReference(SSRModule, "/test/file.tsx", "SidebarTrigger");
|
|
327
|
+
const useSidebar = registerClientReference(SSRModule, "/test/file.tsx", "useSidebar");
|
|
302
328
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|
|
303
329
|
`);
|
|
304
330
|
});
|
|
@@ -319,3 +345,35 @@ describe("transformClientComponents logic branches (from transformClientComponen
|
|
|
319
345
|
expect(result?.code).toEqual("export const foo = 1;");
|
|
320
346
|
});
|
|
321
347
|
});
|
|
348
|
+
describe("transformClientComponents (dev server node_modules)", () => {
|
|
349
|
+
async function transformDev(code, id) {
|
|
350
|
+
process.env.VITE_IS_DEV_SERVER = "1";
|
|
351
|
+
const result = await transformClientComponents(code, id, {
|
|
352
|
+
environmentName: "worker",
|
|
353
|
+
});
|
|
354
|
+
delete process.env.VITE_IS_DEV_SERVER;
|
|
355
|
+
return result?.code;
|
|
356
|
+
}
|
|
357
|
+
it("uses barrel file import for node_modules files in dev", async () => {
|
|
358
|
+
const id = "/test/node_modules/my-lib/component.js";
|
|
359
|
+
const code = `"use client";
|
|
360
|
+
export const MyComponent = () => {};`;
|
|
361
|
+
expect((await transformDev(code, id)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
362
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
363
|
+
const SSRModule = await ssrLoadModule("/test/node_modules/my-lib/component.js");
|
|
364
|
+
const MyComponent = registerClientReference(SSRModule, "/test/node_modules/my-lib/component.js", "MyComponent");
|
|
365
|
+
export { MyComponent };
|
|
366
|
+
`);
|
|
367
|
+
});
|
|
368
|
+
it("uses virtual module import for app source files in dev", async () => {
|
|
369
|
+
const id = "/test/app/component.tsx";
|
|
370
|
+
const code = `"use client";
|
|
371
|
+
export const MyComponent = () => {};`;
|
|
372
|
+
expect((await transformDev(code, id)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
373
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
374
|
+
const SSRModule = await ssrLoadModule("/test/app/component.tsx");
|
|
375
|
+
const MyComponent = registerClientReference(SSRModule, "/test/app/component.tsx", "MyComponent");
|
|
376
|
+
export { MyComponent };
|
|
377
|
+
`);
|
|
378
|
+
});
|
|
379
|
+
});
|
|
@@ -12,5 +12,5 @@ type ExportInfoCompat = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare const findExportedFunctions: (code: string, normalizedId?: string) => Set<string>;
|
|
14
14
|
export declare const findExportInfo: (code: string, normalizedId?: string) => ExportInfoCompat;
|
|
15
|
-
export declare const transformServerFunctions: (code: string, normalizedId: string, environment: "client" | "worker" | "ssr", serverFiles
|
|
15
|
+
export declare const transformServerFunctions: (code: string, normalizedId: string, environment: "client" | "worker" | "ssr", serverFiles: Set<string>) => TransformResult | undefined;
|
|
16
16
|
export type { TransformResult };
|
|
@@ -85,7 +85,7 @@ function hasDefaultExport(code, normalizedId) {
|
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
export const transformServerFunctions = (code, normalizedId, environment, serverFiles) => {
|
|
88
|
-
if (!hasDirective(code, "use server")) {
|
|
88
|
+
if (!serverFiles.has(normalizedId) && !hasDirective(code, "use server")) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
process.env.VERBOSE &&
|
|
@@ -107,15 +107,15 @@ export * from './utils';
|
|
|
107
107
|
for (const [key, CODE] of Object.entries(TEST_CASES)) {
|
|
108
108
|
describe(key, () => {
|
|
109
109
|
it(`CLIENT`, () => {
|
|
110
|
-
const result = transformServerFunctions(CODE, "/test.tsx", "client");
|
|
110
|
+
const result = transformServerFunctions(CODE, "/test.tsx", "client", new Set());
|
|
111
111
|
expect(result?.code).toMatchSnapshot();
|
|
112
112
|
});
|
|
113
113
|
it(`WORKER`, () => {
|
|
114
|
-
const result = transformServerFunctions(CODE, "/test.tsx", "worker");
|
|
114
|
+
const result = transformServerFunctions(CODE, "/test.tsx", "worker", new Set());
|
|
115
115
|
expect(result?.code).toMatchSnapshot();
|
|
116
116
|
});
|
|
117
117
|
it(`SSR`, () => {
|
|
118
|
-
const result = transformServerFunctions(CODE, "/test.tsx", "ssr");
|
|
118
|
+
const result = transformServerFunctions(CODE, "/test.tsx", "ssr", new Set());
|
|
119
119
|
expect(result?.code).toMatchSnapshot();
|
|
120
120
|
});
|
|
121
121
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rwsdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.20",
|
|
4
4
|
"description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -59,6 +59,14 @@
|
|
|
59
59
|
"types": "./dist/runtime/entries/auth.d.ts",
|
|
60
60
|
"default": "./dist/runtime/entries/auth.js"
|
|
61
61
|
},
|
|
62
|
+
"./e2e": {
|
|
63
|
+
"types": "./dist/lib/e2e/index.d.mts",
|
|
64
|
+
"default": "./dist/lib/e2e/index.mjs"
|
|
65
|
+
},
|
|
66
|
+
"./e2e/setup": {
|
|
67
|
+
"types": "./dist/lib/e2e/setup.d.mts",
|
|
68
|
+
"default": "./dist/lib/e2e/setup.mjs"
|
|
69
|
+
},
|
|
62
70
|
"./db": {
|
|
63
71
|
"types": "./dist/runtime/lib/db/index.d.ts",
|
|
64
72
|
"default": "./dist/runtime/lib/db/index.js"
|
|
@@ -124,58 +132,59 @@
|
|
|
124
132
|
"author": "RedwoodSDK <peter@redwoodjs.com>",
|
|
125
133
|
"license": "MIT",
|
|
126
134
|
"dependencies": {
|
|
127
|
-
"@ast-grep/napi": "
|
|
128
|
-
"@cloudflare/workers-types": "
|
|
129
|
-
"@
|
|
130
|
-
"@
|
|
131
|
-
"@types/
|
|
132
|
-
"@types/react
|
|
133
|
-
"@types/react-
|
|
134
|
-
"@
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"kysely
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
"
|
|
135
|
+
"@ast-grep/napi": "~0.39.0",
|
|
136
|
+
"@cloudflare/workers-types": "~4.20250924.0",
|
|
137
|
+
"@mdx-js/mdx": "~3.1.1",
|
|
138
|
+
"@puppeteer/browsers": "~2.10.0",
|
|
139
|
+
"@types/fs-extra": "~11.0.4",
|
|
140
|
+
"@types/react": "~19.1.2",
|
|
141
|
+
"@types/react-dom": "~19.1.2",
|
|
142
|
+
"@types/react-is": "~19.0.0",
|
|
143
|
+
"@vitejs/plugin-react": "~5.0.0",
|
|
144
|
+
"chokidar": "~4.0.0",
|
|
145
|
+
"debug": "~4.4.0",
|
|
146
|
+
"enhanced-resolve": "~5.18.1",
|
|
147
|
+
"eventsource-parser": "~3.0.0",
|
|
148
|
+
"execa": "~9.6.0",
|
|
149
|
+
"fs-extra": "~11.3.0",
|
|
150
|
+
"glob": "~11.0.1",
|
|
151
|
+
"ignore": "~7.0.4",
|
|
152
|
+
"jsonc-parser": "~3.3.1",
|
|
153
|
+
"kysely": "~0.28.2",
|
|
154
|
+
"kysely-do": "~0.0.1-rc.1",
|
|
155
|
+
"lodash": "~4.17.21",
|
|
156
|
+
"magic-string": "~0.30.17",
|
|
157
|
+
"miniflare": "~4.20250924.0",
|
|
158
|
+
"picocolors": "~1.1.1",
|
|
159
|
+
"proper-lockfile": "~4.1.2",
|
|
160
|
+
"puppeteer-core": "~24.22.0",
|
|
161
|
+
"react-is": "~19.1.0",
|
|
162
|
+
"rsc-html-stream": "~0.0.6",
|
|
163
|
+
"tmp-promise": "~3.0.3",
|
|
164
|
+
"ts-morph": "~27.0.0",
|
|
165
|
+
"unique-names-generator": "~4.7.1",
|
|
166
|
+
"vibe-rules": "~0.3.0",
|
|
167
|
+
"vite-tsconfig-paths": "~5.1.4"
|
|
159
168
|
},
|
|
160
169
|
"peerDependencies": {
|
|
161
170
|
"@cloudflare/vite-plugin": "^1.12.4",
|
|
162
|
-
"react": "19.2.0-canary-3fb190f7-20250908",
|
|
163
|
-
"react-dom": "19.2.0-canary-3fb190f7-20250908",
|
|
164
|
-
"react-server-dom-webpack": "19.2.0-canary-3fb190f7-20250908",
|
|
171
|
+
"react": ">=19.2.0-canary-3fb190f7-20250908 <20.0.0",
|
|
172
|
+
"react-dom": ">=19.2.0-canary-3fb190f7-20250908 <20.0.0",
|
|
173
|
+
"react-server-dom-webpack": ">=19.2.0-canary-3fb190f7-20250908 <20.0.0",
|
|
165
174
|
"vite": "^6.2.6 || 7.x",
|
|
166
175
|
"wrangler": "^4.35.0"
|
|
167
176
|
},
|
|
168
|
-
"packageManager": "pnpm@
|
|
177
|
+
"packageManager": "pnpm@10.0.0+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b",
|
|
169
178
|
"devDependencies": {
|
|
170
|
-
"@types/debug": "
|
|
171
|
-
"@types/js-beautify": "
|
|
172
|
-
"@types/lodash": "
|
|
173
|
-
"@types/node": "
|
|
174
|
-
"@types/proper-lockfile": "
|
|
175
|
-
"js-beautify": "
|
|
176
|
-
"semver": "
|
|
177
|
-
"tsx": "
|
|
178
|
-
"typescript": "
|
|
179
|
-
"vitest": "
|
|
179
|
+
"@types/debug": "~4.1.12",
|
|
180
|
+
"@types/js-beautify": "~1.14.3",
|
|
181
|
+
"@types/lodash": "~4.17.16",
|
|
182
|
+
"@types/node": "~24.5.2",
|
|
183
|
+
"@types/proper-lockfile": "~4.1.4",
|
|
184
|
+
"js-beautify": "~1.15.4",
|
|
185
|
+
"semver": "~7.7.1",
|
|
186
|
+
"tsx": "~4.20.0",
|
|
187
|
+
"typescript": "~5.9.0",
|
|
188
|
+
"vitest": "~3.2.0"
|
|
180
189
|
}
|
|
181
190
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveSSRValue: <Value>(clientReference: Value) => Promise<Value>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ssrGetModuleExport } from "rwsdk/__ssr_bridge";
|
|
2
|
-
export const resolveSSRValue = (clientReference) => {
|
|
3
|
-
const id = clientReference.__rwsdk_clientReferenceId;
|
|
4
|
-
if (!id) {
|
|
5
|
-
throw new Error("RWSDK: Client reference is not a client reference");
|
|
6
|
-
}
|
|
7
|
-
return ssrGetModuleExport(id);
|
|
8
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { use } from "react";
|
|
3
|
-
import { renderToReadableStream } from "react-dom/server.edge";
|
|
4
|
-
import { Preloads } from "./preloads.js";
|
|
5
|
-
import { Stylesheets } from "./stylesheets.js";
|
|
6
|
-
export const renderRscThenableToHtmlStream = async ({ thenable, Document, requestInfo, shouldSSR, onError, }) => {
|
|
7
|
-
const Component = () => {
|
|
8
|
-
const RscApp = () => {
|
|
9
|
-
const node = use(thenable).node;
|
|
10
|
-
return (_jsxs(_Fragment, { children: [_jsx(Stylesheets, { requestInfo: requestInfo }), _jsx(Preloads, { requestInfo: requestInfo }), _jsx("div", { id: "hydrate-root", children: node })] }));
|
|
11
|
-
};
|
|
12
|
-
// todo(justinvdm, 18 Jun 2025): We can build on this later to allow users
|
|
13
|
-
// surface context. e.g:
|
|
14
|
-
// * we assign `user: requestInfo.clientCtx` here
|
|
15
|
-
// * user populates requestInfo.clientCtx on worker side
|
|
16
|
-
// * user can import a read only `import { clientCtx } from "rwsdk/client"`
|
|
17
|
-
// on client side
|
|
18
|
-
const clientContext = {
|
|
19
|
-
rw: {
|
|
20
|
-
ssr: shouldSSR,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
return (_jsxs(Document, { ...requestInfo, children: [_jsx("script", { nonce: requestInfo.rw.nonce, dangerouslySetInnerHTML: {
|
|
24
|
-
__html: `globalThis.__RWSDK_CONTEXT = ${JSON.stringify(clientContext)}`,
|
|
25
|
-
} }), _jsx(RscApp, {})] }));
|
|
26
|
-
};
|
|
27
|
-
return await renderToReadableStream(_jsx(Component, {}), {
|
|
28
|
-
nonce: requestInfo.rw.nonce,
|
|
29
|
-
onError(error, { componentStack }) {
|
|
30
|
-
try {
|
|
31
|
-
if (!error) {
|
|
32
|
-
error = new Error(`A falsy value was thrown during rendering: ${String(error)}.`);
|
|
33
|
-
}
|
|
34
|
-
const message = error
|
|
35
|
-
? (error.stack ?? error.message ?? error)
|
|
36
|
-
: error;
|
|
37
|
-
const wrappedMessage = `${message}\n\nComponent stack:${componentStack}`;
|
|
38
|
-
if (error instanceof Error) {
|
|
39
|
-
const wrappedError = new Error(wrappedMessage);
|
|
40
|
-
wrappedError.stack = error.stack;
|
|
41
|
-
error = wrappedError;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
error = new Error(wrappedMessage);
|
|
45
|
-
error.stack = componentStack;
|
|
46
|
-
}
|
|
47
|
-
onError(error);
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
onError(error);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DocumentProps } from "../lib/router";
|
|
2
|
-
import { RequestInfo } from "../requestInfo/types";
|
|
3
|
-
export declare const transformRscToHtmlStream: ({ stream, Document, requestInfo, onError, }: {
|
|
4
|
-
stream: ReadableStream;
|
|
5
|
-
Document: React.FC<DocumentProps>;
|
|
6
|
-
requestInfo: RequestInfo;
|
|
7
|
-
onError: (error: unknown) => void;
|
|
8
|
-
}) => Promise<import("react-dom/server.js").ReactDOMServerReadableStream>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createModuleMap } from "./createModuleMap.js";
|
|
2
|
-
import ReactServerDom from "react-server-dom-webpack/client.edge";
|
|
3
|
-
import { renderRscThenableToHtmlStream } from "rwsdk/__ssr_bridge";
|
|
4
|
-
const { createFromReadableStream } = ReactServerDom;
|
|
5
|
-
export const transformRscToHtmlStream = ({ stream, Document, requestInfo, onError, }) => {
|
|
6
|
-
const thenable = createFromReadableStream(stream, {
|
|
7
|
-
serverConsumerManifest: {
|
|
8
|
-
moduleMap: createModuleMap(),
|
|
9
|
-
moduleLoading: null,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
return renderRscThenableToHtmlStream({
|
|
13
|
-
thenable,
|
|
14
|
-
Document,
|
|
15
|
-
requestInfo,
|
|
16
|
-
shouldSSR: requestInfo.rw.ssr,
|
|
17
|
-
onError,
|
|
18
|
-
});
|
|
19
|
-
};
|
|
File without changes
|