rwsdk 1.0.0-alpha.9 → 1.0.0-beta.1
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/constants.mjs +1 -2
- package/dist/lib/e2e/browser.d.mts +1 -1
- package/dist/lib/e2e/browser.mjs +3 -4
- package/dist/lib/e2e/dev.mjs +62 -52
- package/dist/lib/e2e/environment.d.mts +2 -6
- package/dist/lib/e2e/environment.mjs +72 -72
- package/dist/lib/e2e/index.d.mts +5 -4
- package/dist/lib/e2e/index.mjs +5 -4
- package/dist/lib/e2e/poll.d.mts +8 -0
- package/dist/lib/e2e/poll.mjs +31 -0
- package/dist/lib/e2e/release.mjs +4 -4
- 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 +3 -2
- package/dist/lib/e2e/tarball.mjs +30 -5
- package/dist/lib/e2e/testHarness.d.mts +59 -50
- package/dist/lib/e2e/testHarness.mjs +289 -343
- package/dist/lib/getShortName.mjs +1 -2
- package/dist/lib/getShortName.test.mjs +2 -2
- package/dist/lib/getSrcPaths.js +2 -2
- package/dist/lib/hasPkgScript.test.mjs +2 -2
- package/dist/lib/jsonUtils.test.mjs +2 -2
- package/dist/lib/normalizeModulePath.test.mjs +2 -2
- package/dist/lib/setupEnvFiles.mjs +2 -2
- package/dist/lib/smokeTests/artifacts.mjs +2 -2
- package/dist/lib/smokeTests/browser.d.mts +1 -1
- package/dist/lib/smokeTests/browser.mjs +6 -7
- package/dist/lib/smokeTests/cleanup.mjs +6 -9
- package/dist/lib/smokeTests/codeUpdates.mjs +5 -5
- package/dist/lib/smokeTests/development.mjs +2 -2
- package/dist/lib/smokeTests/environment.d.mts +2 -3
- package/dist/lib/smokeTests/environment.mjs +17 -3
- package/dist/lib/smokeTests/release.d.mts +2 -2
- package/dist/lib/smokeTests/release.mjs +3 -3
- package/dist/lib/smokeTests/reporting.mjs +2 -2
- package/dist/lib/smokeTests/runSmokeTests.mjs +4 -4
- package/dist/lib/smokeTests/utils.mjs +3 -3
- package/dist/lib/testUtils/stubEnvVars.mjs +1 -1
- package/dist/llms/rules/middleware.d.ts +1 -1
- package/dist/llms/rules/middleware.js +4 -4
- package/dist/runtime/client/client.d.ts +2 -2
- package/dist/runtime/client/client.js +2 -2
- package/dist/runtime/client/navigation.test.js +1 -1
- package/dist/runtime/client/types.d.ts +1 -1
- package/dist/runtime/entries/client.d.ts +2 -2
- package/dist/runtime/entries/client.js +2 -2
- package/dist/runtime/entries/router.d.ts +1 -1
- package/dist/runtime/entries/router.js +1 -1
- package/dist/runtime/entries/worker.d.ts +5 -6
- package/dist/runtime/entries/worker.js +5 -6
- package/dist/runtime/imports/worker.js +1 -1
- package/dist/runtime/lib/auth/session.d.ts +2 -2
- package/dist/runtime/lib/auth/session.js +5 -5
- package/dist/runtime/lib/db/DOWorkerDialect.d.ts +1 -1
- package/dist/runtime/lib/db/DOWorkerDialect.js +1 -1
- package/dist/runtime/lib/db/SqliteDurableObject.js +2 -2
- package/dist/runtime/lib/db/index.d.ts +2 -2
- package/dist/runtime/lib/db/index.js +2 -2
- package/dist/runtime/lib/db/migrations.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +3 -3
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +2 -2
- package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +3 -3
- package/dist/runtime/lib/db/typeInference/database.d.ts +2 -2
- package/dist/runtime/lib/memoizeOnId.test.js +1 -1
- package/dist/runtime/lib/realtime/client.js +2 -2
- package/dist/runtime/lib/realtime/durableObject.js +1 -1
- package/dist/runtime/lib/realtime/protocol.test.js +1 -1
- package/dist/runtime/lib/realtime/shared.test.js +1 -1
- package/dist/runtime/lib/realtime/validateUpgradeRequest.test.js +1 -1
- package/dist/runtime/lib/realtime/worker.js +2 -2
- package/dist/runtime/lib/router.d.ts +1 -1
- package/dist/runtime/lib/router.test.js +2 -3
- package/dist/runtime/lib/rwContext.d.ts +1 -1
- package/dist/runtime/lib/stitchDocumentAndAppStreams.d.ts +18 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.js +143 -0
- package/dist/runtime/lib/turnstile/useTurnstile.js +1 -1
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.test.js +1 -1
- package/dist/runtime/register/worker.d.ts +1 -1
- package/dist/runtime/register/worker.js +34 -22
- package/dist/runtime/render/assembleDocument.d.ts +1 -1
- package/dist/runtime/render/createThenableFromReadableStream.js +1 -1
- package/dist/runtime/render/preloads.d.ts +2 -2
- package/dist/runtime/render/renderDocumentHtmlStream.js +6 -6
- package/dist/runtime/render/renderHtmlStream.d.ts +1 -1
- package/dist/runtime/render/renderToRscStream.d.ts +4 -1
- package/dist/runtime/render/renderToRscStream.js +11 -1
- package/dist/runtime/render/renderToStream.d.ts +1 -1
- package/dist/runtime/render/renderToStream.js +2 -2
- package/dist/runtime/render/stylesheets.d.ts +1 -1
- package/dist/runtime/requestInfo/types.d.ts +0 -2
- package/dist/runtime/requestInfo/worker.d.ts +1 -1
- package/dist/runtime/requestInfo/worker.js +1 -9
- package/dist/runtime/script.js +1 -1
- package/dist/runtime/ssrBridge.d.ts +2 -2
- package/dist/runtime/ssrBridge.js +2 -2
- package/dist/runtime/worker.d.ts +1 -1
- package/dist/runtime/worker.js +3 -11
- package/dist/scripts/addon.d.mts +1 -0
- package/dist/scripts/addon.mjs +73 -0
- package/dist/scripts/debug-sync.mjs +106 -137
- package/dist/scripts/ensure-deploy-env.mjs +6 -6
- package/dist/scripts/migrate-new.mjs +3 -4
- package/dist/scripts/smoke-test.mjs +2 -9
- package/dist/scripts/worker-run.mjs +7 -9
- package/dist/vite/buildApp.mjs +1 -1
- package/dist/vite/checkIsUsingPrisma.test.mjs +1 -1
- package/dist/vite/configPlugin.mjs +33 -6
- package/dist/vite/createDirectiveLookupPlugin.mjs +1 -1
- package/dist/vite/createDirectiveLookupPlugin.test.mjs +2 -2
- package/dist/vite/createViteAwareResolver.d.mts +1 -2
- package/dist/vite/createViteAwareResolver.mjs +1 -1
- package/dist/vite/directiveModulesDevPlugin.mjs +4 -4
- package/dist/vite/directiveModulesDevPlugin.test.mjs +2 -2
- package/dist/vite/directivesPlugin.mjs +3 -3
- package/dist/vite/directivesPlugin.test.mjs +1 -1
- package/dist/vite/ensureAliasArray.test.mjs +1 -1
- package/dist/vite/findSpecifiers.mjs +1 -1
- package/dist/vite/findSpecifiers.test.mjs +2 -2
- package/dist/vite/findSsrSpecifiers.mjs +1 -1
- package/dist/vite/findSsrSpecifiers.test.mjs +1 -1
- package/dist/vite/getViteEsbuild.mjs +1 -1
- package/dist/vite/hasDirective.test.mjs +1 -1
- package/dist/vite/index.d.mts +1 -1
- package/dist/vite/invalidateCacheIfPrismaClientChanged.mjs +2 -2
- package/dist/vite/isJsFile.test.mjs +1 -1
- package/dist/vite/{reactConditionsResolverPlugin.d.mts → knownDepsResolverPlugin.d.mts} +3 -3
- package/dist/vite/{reactConditionsResolverPlugin.mjs → knownDepsResolverPlugin.mjs} +29 -24
- package/dist/vite/linkerPlugin.mjs +2 -2
- package/dist/vite/linkerPlugin.test.mjs +1 -1
- package/dist/vite/miniflareHMRPlugin.mjs +5 -5
- package/dist/vite/miniflareHMRPlugin.test.mjs +1 -1
- package/dist/vite/prismaPlugin.mjs +1 -1
- package/dist/vite/redwoodPlugin.d.mts +2 -0
- package/dist/vite/redwoodPlugin.mjs +36 -17
- package/dist/vite/redwoodPlugin.test.mjs +2 -2
- package/dist/vite/resolveForcedPaths.d.mts +4 -0
- package/dist/vite/resolveForcedPaths.mjs +9 -0
- package/dist/vite/runDirectivesScan.d.mts +2 -1
- package/dist/vite/runDirectivesScan.mjs +53 -17
- package/dist/vite/runDirectivesScan.test.mjs +2 -2
- package/dist/vite/ssrBridgePlugin.mjs +10 -3
- package/dist/vite/transformClientComponents.mjs +8 -6
- package/dist/vite/transformClientComponents.test.mjs +117 -59
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +1 -1
- package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +2 -2
- package/dist/vite/transformServerFunctions.d.mts +1 -1
- package/dist/vite/transformServerFunctions.mjs +5 -5
- package/dist/vite/transformServerFunctions.test.mjs +3 -3
- package/package.json +54 -44
- package/dist/runtime/imports/resolveSSRValue.d.ts +0 -1
- package/dist/runtime/imports/resolveSSRValue.js +0 -8
- package/dist/runtime/lib/injectHtmlAtMarker.d.ts +0 -11
- package/dist/runtime/lib/injectHtmlAtMarker.js +0 -90
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe,
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { transformClientComponents } from "./transformClientComponents.mjs";
|
|
3
3
|
describe("transformClientComponents", () => {
|
|
4
4
|
async function transform(code) {
|
|
@@ -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
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Project, Node, SyntaxKind, } from "ts-morph";
|
|
2
1
|
import debug from "debug";
|
|
2
|
+
import { Node, Project, SyntaxKind, } from "ts-morph";
|
|
3
3
|
import { normalizeModulePath } from "../lib/normalizeModulePath.mjs";
|
|
4
4
|
const log = debug("rwsdk:vite:transform-jsx-script-tags");
|
|
5
5
|
function transformAssetPath(importPath, projectRootDir) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
-
import { transformJsxScriptTagsCode } from "./transformJsxScriptTagsPlugin.mjs";
|
|
3
1
|
import jsBeautify from "js-beautify";
|
|
2
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
4
3
|
import stubEnvVars from "../lib/testUtils/stubEnvVars.mjs";
|
|
4
|
+
import { transformJsxScriptTagsCode } from "./transformJsxScriptTagsPlugin.mjs";
|
|
5
5
|
// Helper function to normalize code formatting for test comparisons
|
|
6
6
|
function normalizeCode(code) {
|
|
7
7
|
return jsBeautify(code, { indent_size: 2 });
|
|
@@ -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 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Lang, Lang as SgLang, parse as sgParse } from "@ast-grep/napi";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import
|
|
4
|
-
import { findExports } from "./findSpecifiers.mjs";
|
|
5
|
-
import { parse as sgParse, Lang as SgLang, Lang } from "@ast-grep/napi";
|
|
3
|
+
import MagicString from "magic-string";
|
|
6
4
|
import path from "path";
|
|
5
|
+
import { findExports } from "./findSpecifiers.mjs";
|
|
6
|
+
import { hasDirective } from "./hasDirective.mjs";
|
|
7
7
|
const log = debug("rwsdk:vite:transform-server-functions");
|
|
8
8
|
export const findExportedFunctions = (code, normalizedId) => {
|
|
9
9
|
return findExportInfo(code, normalizedId).localFunctions;
|
|
@@ -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,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rwsdk",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"rw-scripts": "./bin/rw-scripts.mjs",
|
|
8
|
+
"rwsdk": "./bin/rw-scripts.mjs",
|
|
8
9
|
"rwsync": "./bin/rwsync"
|
|
9
10
|
},
|
|
10
11
|
"files": [
|
|
@@ -63,6 +64,10 @@
|
|
|
63
64
|
"types": "./dist/lib/e2e/index.d.mts",
|
|
64
65
|
"default": "./dist/lib/e2e/index.mjs"
|
|
65
66
|
},
|
|
67
|
+
"./e2e/setup": {
|
|
68
|
+
"types": "./dist/lib/e2e/setup.d.mts",
|
|
69
|
+
"default": "./dist/lib/e2e/setup.mjs"
|
|
70
|
+
},
|
|
66
71
|
"./db": {
|
|
67
72
|
"types": "./dist/runtime/lib/db/index.d.ts",
|
|
68
73
|
"default": "./dist/runtime/lib/db/index.js"
|
|
@@ -128,38 +133,41 @@
|
|
|
128
133
|
"author": "RedwoodSDK <peter@redwoodjs.com>",
|
|
129
134
|
"license": "MIT",
|
|
130
135
|
"dependencies": {
|
|
131
|
-
"@ast-grep/napi": "
|
|
132
|
-
"@cloudflare/workers-types": "
|
|
133
|
-
"@
|
|
134
|
-
"@
|
|
135
|
-
"@types/
|
|
136
|
-
"@types/
|
|
137
|
-
"@types/react
|
|
138
|
-
"@
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"
|
|
136
|
+
"@ast-grep/napi": "~0.39.0",
|
|
137
|
+
"@cloudflare/workers-types": "~4.20250924.0",
|
|
138
|
+
"@mdx-js/mdx": "~3.1.1",
|
|
139
|
+
"@puppeteer/browsers": "~2.10.0",
|
|
140
|
+
"@types/decompress": "~4.2.7",
|
|
141
|
+
"@types/fs-extra": "~11.0.4",
|
|
142
|
+
"@types/react": "~19.1.2",
|
|
143
|
+
"@types/react-dom": "~19.1.2",
|
|
144
|
+
"@types/react-is": "~19.0.0",
|
|
145
|
+
"@vitejs/plugin-react": "~5.0.0",
|
|
146
|
+
"chokidar": "~4.0.0",
|
|
147
|
+
"debug": "~4.4.0",
|
|
148
|
+
"enhanced-resolve": "~5.18.1",
|
|
149
|
+
"eventsource-parser": "~3.0.0",
|
|
150
|
+
"execa": "~9.6.0",
|
|
151
|
+
"find-up": "~8.0.0",
|
|
152
|
+
"fs-extra": "~11.3.0",
|
|
153
|
+
"glob": "~11.0.1",
|
|
154
|
+
"ignore": "~7.0.4",
|
|
155
|
+
"jsonc-parser": "~3.3.1",
|
|
156
|
+
"kysely": "~0.28.2",
|
|
157
|
+
"kysely-do": "~0.0.1-rc.1",
|
|
158
|
+
"lodash": "~4.17.21",
|
|
159
|
+
"magic-string": "~0.30.17",
|
|
160
|
+
"picocolors": "~1.1.1",
|
|
161
|
+
"proper-lockfile": "~4.1.2",
|
|
162
|
+
"puppeteer-core": "~24.22.0",
|
|
163
|
+
"react-is": "~19.1.0",
|
|
164
|
+
"rsc-html-stream": "~0.0.6",
|
|
165
|
+
"tmp-promise": "~3.0.3",
|
|
166
|
+
"ts-morph": "~27.0.0",
|
|
167
|
+
"unique-names-generator": "~4.7.1",
|
|
168
|
+
"vibe-rules": "~0.3.0",
|
|
169
|
+
"vite-tsconfig-paths": "~5.1.4",
|
|
170
|
+
"decompress": "~4.2.1"
|
|
163
171
|
},
|
|
164
172
|
"peerDependencies": {
|
|
165
173
|
"@cloudflare/vite-plugin": "^1.12.4",
|
|
@@ -169,17 +177,19 @@
|
|
|
169
177
|
"vite": "^6.2.6 || 7.x",
|
|
170
178
|
"wrangler": "^4.35.0"
|
|
171
179
|
},
|
|
172
|
-
"packageManager": "pnpm@
|
|
180
|
+
"packageManager": "pnpm@10.0.0+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b",
|
|
173
181
|
"devDependencies": {
|
|
174
|
-
"@
|
|
175
|
-
"@types/
|
|
176
|
-
"@types/
|
|
177
|
-
"@types/
|
|
178
|
-
"@types/
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
182
|
+
"@cloudflare/vite-plugin": "1.13.3",
|
|
183
|
+
"@types/debug": "~4.1.12",
|
|
184
|
+
"@types/js-beautify": "~1.14.3",
|
|
185
|
+
"@types/lodash": "~4.17.16",
|
|
186
|
+
"@types/node": "~24.5.2",
|
|
187
|
+
"@types/proper-lockfile": "~4.1.4",
|
|
188
|
+
"js-beautify": "~1.15.4",
|
|
189
|
+
"semver": "~7.7.1",
|
|
190
|
+
"tsx": "~4.20.0",
|
|
191
|
+
"typescript": "~5.9.0",
|
|
192
|
+
"vite": "7.1.6",
|
|
193
|
+
"vitest": "~3.2.0"
|
|
184
194
|
}
|
|
185
195
|
}
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Injects HTML content from one stream into another stream at a specified marker.
|
|
3
|
-
* This preserves streaming behavior by processing chunks incrementally without
|
|
4
|
-
* buffering the entire streams.
|
|
5
|
-
*
|
|
6
|
-
* @param outerHtml - The outer HTML stream containing the marker
|
|
7
|
-
* @param innerHtml - The inner HTML stream to inject at the marker
|
|
8
|
-
* @param marker - The text marker where injection should occur
|
|
9
|
-
* @returns A new ReadableStream with the inner HTML injected at the marker
|
|
10
|
-
*/
|
|
11
|
-
export declare function injectHtmlAtMarker(outerHtml: ReadableStream<Uint8Array>, innerHtml: ReadableStream<Uint8Array>, marker: string): ReadableStream<Uint8Array>;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Injects HTML content from one stream into another stream at a specified marker.
|
|
3
|
-
* This preserves streaming behavior by processing chunks incrementally without
|
|
4
|
-
* buffering the entire streams.
|
|
5
|
-
*
|
|
6
|
-
* @param outerHtml - The outer HTML stream containing the marker
|
|
7
|
-
* @param innerHtml - The inner HTML stream to inject at the marker
|
|
8
|
-
* @param marker - The text marker where injection should occur
|
|
9
|
-
* @returns A new ReadableStream with the inner HTML injected at the marker
|
|
10
|
-
*/
|
|
11
|
-
export function injectHtmlAtMarker(outerHtml, innerHtml, marker) {
|
|
12
|
-
const decoder = new TextDecoder();
|
|
13
|
-
const encoder = new TextEncoder();
|
|
14
|
-
let buffer = "";
|
|
15
|
-
let injected = false;
|
|
16
|
-
return new ReadableStream({
|
|
17
|
-
async start(controller) {
|
|
18
|
-
const outerReader = outerHtml.getReader();
|
|
19
|
-
const flushText = (text) => {
|
|
20
|
-
if (text.length > 0) {
|
|
21
|
-
controller.enqueue(encoder.encode(text));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const pumpInnerStream = async () => {
|
|
25
|
-
const innerReader = innerHtml.getReader();
|
|
26
|
-
try {
|
|
27
|
-
while (true) {
|
|
28
|
-
const { done, value } = await innerReader.read();
|
|
29
|
-
if (done) {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
controller.enqueue(value);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
innerReader.releaseLock();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
try {
|
|
40
|
-
while (true) {
|
|
41
|
-
const { done, value } = await outerReader.read();
|
|
42
|
-
if (done) {
|
|
43
|
-
// End of outer stream - flush any remaining buffer
|
|
44
|
-
if (buffer.length > 0) {
|
|
45
|
-
flushText(buffer);
|
|
46
|
-
}
|
|
47
|
-
controller.close();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
// Decode the chunk and add to buffer
|
|
51
|
-
buffer += decoder.decode(value, { stream: true });
|
|
52
|
-
if (!injected) {
|
|
53
|
-
// Look for the marker in the buffer
|
|
54
|
-
const markerIndex = buffer.indexOf(marker);
|
|
55
|
-
if (markerIndex !== -1) {
|
|
56
|
-
// Found the marker - emit everything before it
|
|
57
|
-
flushText(buffer.slice(0, markerIndex));
|
|
58
|
-
// Inject the inner HTML stream
|
|
59
|
-
await pumpInnerStream();
|
|
60
|
-
// Keep everything after the marker for next iteration
|
|
61
|
-
buffer = buffer.slice(markerIndex + marker.length);
|
|
62
|
-
injected = true;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
// Marker not found yet - flush all but potential partial marker
|
|
66
|
-
// Keep overlap to handle markers split across chunks
|
|
67
|
-
const overlap = Math.max(0, marker.length - 1);
|
|
68
|
-
const cutoff = Math.max(0, buffer.length - overlap);
|
|
69
|
-
if (cutoff > 0) {
|
|
70
|
-
flushText(buffer.slice(0, cutoff));
|
|
71
|
-
buffer = buffer.slice(cutoff);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Already injected - just pass through remaining content
|
|
77
|
-
flushText(buffer);
|
|
78
|
-
buffer = "";
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
controller.error(error);
|
|
84
|
-
}
|
|
85
|
-
finally {
|
|
86
|
-
outerReader.releaseLock();
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
}
|