rwsdk 1.0.0-beta.5 → 1.0.0-beta.51
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/bin/rw-scripts.mjs +13 -13
- package/dist/lib/constants.d.mts +1 -0
- package/dist/lib/constants.mjs +7 -4
- package/dist/lib/e2e/browser.mjs +6 -2
- package/dist/lib/e2e/constants.d.mts +4 -0
- package/dist/lib/e2e/constants.mjs +49 -12
- package/dist/lib/e2e/dev.mjs +49 -57
- package/dist/lib/e2e/environment.d.mts +2 -0
- package/dist/lib/e2e/environment.mjs +201 -64
- package/dist/lib/e2e/index.d.mts +2 -0
- package/dist/lib/e2e/index.mjs +2 -0
- package/dist/lib/e2e/poll.d.mts +1 -1
- package/dist/lib/e2e/release.d.mts +1 -0
- package/dist/lib/e2e/release.mjs +57 -52
- package/dist/lib/e2e/tarball.mjs +2 -34
- package/dist/lib/e2e/testHarness.d.mts +39 -3
- package/dist/lib/e2e/testHarness.mjs +239 -92
- package/dist/lib/e2e/utils.d.mts +1 -0
- package/dist/lib/e2e/utils.mjs +15 -0
- package/dist/lib/normalizeModulePath.mjs +1 -1
- package/dist/runtime/client/client.d.ts +64 -2
- package/dist/runtime/client/client.js +156 -15
- package/dist/runtime/client/navigation.d.ts +45 -0
- package/dist/runtime/client/navigation.js +68 -14
- package/dist/runtime/client/navigationCache.d.ts +68 -0
- package/dist/runtime/client/navigationCache.js +294 -0
- package/dist/runtime/client/navigationCache.test.js +469 -0
- package/dist/runtime/client/types.d.ts +26 -5
- package/dist/runtime/client/types.js +8 -1
- package/dist/runtime/entries/no-react-server-ssr-bridge.d.ts +0 -0
- package/dist/runtime/entries/no-react-server-ssr-bridge.js +2 -0
- package/dist/runtime/entries/no-react-server.js +3 -1
- package/dist/runtime/entries/react-server-only.js +1 -1
- package/dist/runtime/entries/router.d.ts +1 -0
- package/dist/runtime/entries/routerClient.d.ts +1 -0
- package/dist/runtime/entries/routerClient.js +1 -0
- package/dist/runtime/entries/worker.d.ts +4 -0
- package/dist/runtime/entries/worker.js +4 -0
- package/dist/runtime/imports/__mocks__/use-client-lookup.d.ts +6 -0
- package/dist/runtime/imports/__mocks__/use-client-lookup.js +6 -0
- package/dist/runtime/lib/db/SqliteDurableObject.d.ts +2 -2
- package/dist/runtime/lib/db/SqliteDurableObject.js +2 -2
- package/dist/runtime/lib/db/createDb.d.ts +1 -2
- package/dist/runtime/lib/db/createDb.js +4 -0
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +13 -3
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +35 -21
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +9 -2
- package/dist/runtime/lib/db/typeInference/database.d.ts +16 -2
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +80 -5
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +104 -2
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +1 -0
- package/dist/runtime/lib/db/typeInference/utils.d.ts +59 -9
- package/dist/runtime/lib/links.d.ts +21 -7
- package/dist/runtime/lib/links.js +84 -26
- package/dist/runtime/lib/links.test.d.ts +1 -0
- package/dist/runtime/lib/links.test.js +20 -0
- package/dist/runtime/lib/manifest.d.ts +1 -1
- package/dist/runtime/lib/manifest.js +7 -4
- package/dist/runtime/lib/realtime/client.js +28 -6
- package/dist/runtime/lib/realtime/worker.d.ts +1 -1
- package/dist/runtime/lib/router.d.ts +154 -35
- package/dist/runtime/lib/router.js +491 -105
- package/dist/runtime/lib/router.test.js +611 -1
- package/dist/runtime/lib/stitchDocumentAndAppStreams.d.ts +66 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.js +302 -35
- package/dist/runtime/lib/stitchDocumentAndAppStreams.test.d.ts +1 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.test.js +418 -0
- package/dist/runtime/lib/{rwContext.d.ts → types.d.ts} +1 -0
- package/dist/runtime/lib/types.js +1 -0
- package/dist/runtime/register/client.d.ts +1 -1
- package/dist/runtime/register/client.js +10 -3
- package/dist/runtime/register/worker.js +13 -4
- package/dist/runtime/render/normalizeActionResult.js +8 -1
- package/dist/runtime/render/renderDocumentHtmlStream.d.ts +1 -1
- package/dist/runtime/render/renderToStream.d.ts +4 -2
- package/dist/runtime/render/renderToStream.js +53 -24
- package/dist/runtime/render/renderToString.d.ts +3 -6
- package/dist/runtime/requestInfo/types.d.ts +5 -1
- package/dist/runtime/requestInfo/utils.d.ts +9 -0
- package/dist/runtime/requestInfo/utils.js +45 -0
- package/dist/runtime/requestInfo/worker.d.ts +0 -1
- package/dist/runtime/requestInfo/worker.js +5 -11
- package/dist/runtime/script.d.ts +1 -3
- package/dist/runtime/script.js +1 -10
- package/dist/runtime/server.d.ts +52 -0
- package/dist/runtime/server.js +88 -0
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +13 -0
- package/dist/runtime/worker.d.ts +3 -1
- package/dist/runtime/worker.js +45 -2
- package/dist/scripts/debug-sync.mjs +18 -20
- package/dist/scripts/worker-run.d.mts +1 -1
- package/dist/scripts/worker-run.mjs +59 -113
- package/dist/use-synced-state/SyncedStateServer.d.mts +36 -0
- package/dist/use-synced-state/SyncedStateServer.mjs +196 -0
- package/dist/use-synced-state/__tests__/SyncStateServer.test.d.mts +1 -0
- package/dist/use-synced-state/__tests__/SyncStateServer.test.mjs +116 -0
- package/dist/use-synced-state/__tests__/useSyncState.test.d.ts +1 -0
- package/dist/use-synced-state/__tests__/useSyncState.test.js +115 -0
- package/dist/use-synced-state/__tests__/useSyncedState.test.d.ts +1 -0
- package/dist/use-synced-state/__tests__/useSyncedState.test.js +115 -0
- package/dist/use-synced-state/__tests__/worker.test.d.mts +1 -0
- package/dist/use-synced-state/__tests__/worker.test.mjs +70 -0
- package/dist/use-synced-state/client-core.d.ts +29 -0
- package/dist/use-synced-state/client-core.js +103 -0
- package/dist/use-synced-state/client.d.ts +3 -0
- package/dist/use-synced-state/client.js +4 -0
- package/dist/use-synced-state/constants.d.mts +1 -0
- package/dist/use-synced-state/constants.mjs +1 -0
- package/dist/use-synced-state/useSyncedState.d.ts +21 -0
- package/dist/use-synced-state/useSyncedState.js +64 -0
- package/dist/use-synced-state/worker.d.mts +14 -0
- package/dist/use-synced-state/worker.mjs +135 -0
- package/dist/vite/buildApp.mjs +34 -2
- package/dist/vite/cloudflarePreInitPlugin.d.mts +11 -0
- package/dist/vite/cloudflarePreInitPlugin.mjs +40 -0
- package/dist/vite/configPlugin.mjs +9 -14
- package/dist/vite/constants.d.mts +1 -0
- package/dist/vite/constants.mjs +1 -0
- package/dist/vite/createDirectiveLookupPlugin.mjs +10 -7
- package/dist/vite/devServerTimingPlugin.mjs +4 -0
- package/dist/vite/diagnosticAssetGraphPlugin.d.mts +4 -0
- package/dist/vite/diagnosticAssetGraphPlugin.mjs +41 -0
- package/dist/vite/directiveModulesDevPlugin.mjs +9 -1
- package/dist/vite/directivesPlugin.mjs +4 -4
- package/dist/vite/envResolvers.d.mts +11 -0
- package/dist/vite/envResolvers.mjs +20 -0
- package/dist/vite/getViteEsbuild.mjs +2 -1
- package/dist/vite/hmrStabilityPlugin.d.mts +2 -0
- package/dist/vite/hmrStabilityPlugin.mjs +73 -0
- package/dist/vite/injectVitePreamblePlugin.mjs +0 -4
- package/dist/vite/knownDepsResolverPlugin.d.mts +0 -6
- package/dist/vite/knownDepsResolverPlugin.mjs +25 -17
- package/dist/vite/linkerPlugin.d.mts +2 -1
- package/dist/vite/linkerPlugin.mjs +11 -3
- package/dist/vite/linkerPlugin.test.mjs +15 -0
- package/dist/vite/miniflareHMRPlugin.mjs +6 -38
- package/dist/vite/moveStaticAssetsPlugin.mjs +35 -4
- package/dist/vite/redwoodPlugin.mjs +9 -11
- package/dist/vite/redwoodPlugin.test.mjs +4 -4
- package/dist/vite/runDirectivesScan.mjs +75 -19
- package/dist/vite/ssrBridgePlugin.mjs +132 -40
- package/dist/vite/ssrBridgeWrapPlugin.d.mts +2 -0
- package/dist/vite/ssrBridgeWrapPlugin.mjs +85 -0
- package/dist/vite/staleDepRetryPlugin.d.mts +2 -0
- package/dist/vite/staleDepRetryPlugin.mjs +74 -0
- package/dist/vite/statePlugin.d.mts +4 -0
- package/dist/vite/statePlugin.mjs +62 -0
- package/dist/vite/transformClientComponents.test.mjs +32 -0
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +0 -5
- package/dist/vite/transformServerFunctions.mjs +66 -4
- package/dist/vite/transformServerFunctions.test.mjs +35 -0
- package/dist/vite/virtualPlugin.mjs +6 -7
- package/package.json +45 -20
- package/dist/vite/manifestPlugin.d.mts +0 -4
- package/dist/vite/manifestPlugin.mjs +0 -63
- /package/dist/runtime/{lib/rwContext.js → client/navigationCache.test.d.ts} +0 -0
|
@@ -288,6 +288,7 @@ function SidebarGroup() { return jsx("div", {}); }
|
|
|
288
288
|
function SidebarGroupLabel() { return jsx("div", {}); }
|
|
289
289
|
function SidebarGroupAction() { return jsx("div", {}); }
|
|
290
290
|
function SidebarGroupContent() { return jsx("div", {}); }
|
|
291
|
+
function SidebarGroupContent() { return jsx("div", {}); }
|
|
291
292
|
function SidebarMenu() { return jsx("div", {}); }
|
|
292
293
|
function SidebarMenuItem() { return jsx("div", {}); }
|
|
293
294
|
function SidebarMenuButton() { return jsx("div", {}); }
|
|
@@ -326,6 +327,37 @@ const SidebarSeparator = registerClientReference(SSRModule, "/test/file.tsx", "S
|
|
|
326
327
|
const SidebarTrigger = registerClientReference(SSRModule, "/test/file.tsx", "SidebarTrigger");
|
|
327
328
|
const useSidebar = registerClientReference(SSRModule, "/test/file.tsx", "useSidebar");
|
|
328
329
|
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 };
|
|
330
|
+
`);
|
|
331
|
+
});
|
|
332
|
+
it("does not transform inlined functions (Issue #471)", async () => {
|
|
333
|
+
const code = `"use client"
|
|
334
|
+
|
|
335
|
+
export function Stars({ level }) {
|
|
336
|
+
const renderStars = (level) => {
|
|
337
|
+
return level;
|
|
338
|
+
}
|
|
339
|
+
return renderStars(level);
|
|
340
|
+
}`;
|
|
341
|
+
expect((await transform(code)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
342
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
343
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
344
|
+
const Stars = registerClientReference(SSRModule, "/test/file.tsx", "Stars");
|
|
345
|
+
export { Stars };
|
|
346
|
+
`);
|
|
347
|
+
});
|
|
348
|
+
it("does not transform inlined functions in default export (Issue #471)", async () => {
|
|
349
|
+
const code = `"use client"
|
|
350
|
+
|
|
351
|
+
export default function Stars({ level }) {
|
|
352
|
+
const renderStars = (level) => {
|
|
353
|
+
return level;
|
|
354
|
+
}
|
|
355
|
+
return renderStars(level);
|
|
356
|
+
}`;
|
|
357
|
+
expect((await transform(code)) ?? "").toEqual(`import { ssrLoadModule } from "rwsdk/__ssr_bridge";
|
|
358
|
+
import { registerClientReference } from "rwsdk/worker";
|
|
359
|
+
const SSRModule = await ssrLoadModule("/test/file.tsx");
|
|
360
|
+
export default registerClientReference(SSRModule, "/test/file.tsx", "default");
|
|
329
361
|
`);
|
|
330
362
|
});
|
|
331
363
|
});
|
|
@@ -319,10 +319,6 @@ export const transformJsxScriptTagsPlugin = ({ clientEntryPoints, projectRootDir
|
|
|
319
319
|
isBuild = config.command === "build";
|
|
320
320
|
},
|
|
321
321
|
async transform(code, id) {
|
|
322
|
-
// Skip during directive scanning to avoid performance issues
|
|
323
|
-
if (process.env.RWSDK_DIRECTIVE_SCAN_ACTIVE) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
322
|
if (isBuild &&
|
|
327
323
|
this.environment?.name === "worker" &&
|
|
328
324
|
process.env.RWSDK_BUILD_PASS !== "worker") {
|
|
@@ -330,7 +326,6 @@ export const transformJsxScriptTagsPlugin = ({ clientEntryPoints, projectRootDir
|
|
|
330
326
|
}
|
|
331
327
|
if (this.environment?.name === "worker" &&
|
|
332
328
|
id.endsWith(".tsx") &&
|
|
333
|
-
!id.includes("node_modules") &&
|
|
334
329
|
hasJsxFunctions(code)) {
|
|
335
330
|
log("Transforming JSX script tags in %s", id);
|
|
336
331
|
process.env.VERBOSE && log("Code:\n%s", code);
|
|
@@ -111,16 +111,78 @@ export const transformServerFunctions = (code, normalizedId, environment, server
|
|
|
111
111
|
else {
|
|
112
112
|
s.append('import { createServerReference } from "rwsdk/client";\n\n');
|
|
113
113
|
}
|
|
114
|
+
const ext = path.extname(normalizedId).toLowerCase();
|
|
115
|
+
const lang = ext === ".tsx" || ext === ".jsx" ? Lang.Tsx : SgLang.TypeScript;
|
|
116
|
+
const root = sgParse(lang, code);
|
|
114
117
|
for (const name of allExports) {
|
|
115
118
|
if (name !== "default" && name !== defaultFunctionName) {
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
let method;
|
|
120
|
+
let source = "action";
|
|
121
|
+
// Try to find if this export is a serverQuery or serverAction call to extract the method
|
|
122
|
+
const patterns = [
|
|
123
|
+
`export const ${name} = serverQuery($$$, { method: "$METHOD" })`,
|
|
124
|
+
`export const ${name} = serverQuery($$$)`,
|
|
125
|
+
`export const ${name} = serverAction($$$)`,
|
|
126
|
+
];
|
|
127
|
+
for (const pattern of patterns) {
|
|
128
|
+
const matches = root.root().findAll(pattern);
|
|
129
|
+
if (matches.length > 0) {
|
|
130
|
+
if (pattern.includes("serverQuery")) {
|
|
131
|
+
const methodMatch = matches[0].getMatch("METHOD");
|
|
132
|
+
method = methodMatch ? methodMatch.text() : "GET";
|
|
133
|
+
source = "query";
|
|
134
|
+
}
|
|
135
|
+
else if (pattern.includes("serverAction")) {
|
|
136
|
+
method = "POST";
|
|
137
|
+
source = "action";
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
let extraArgs = "";
|
|
143
|
+
if (source === "query") {
|
|
144
|
+
extraArgs = `, ${JSON.stringify(method ?? "GET")}, "query"`;
|
|
145
|
+
}
|
|
146
|
+
else if (method !== undefined) {
|
|
147
|
+
extraArgs = `, ${JSON.stringify(method)}`;
|
|
148
|
+
}
|
|
149
|
+
s.append(`export let ${name} = createServerReference(${JSON.stringify(normalizedId)}, ${JSON.stringify(name)}${extraArgs});\n`);
|
|
150
|
+
log(`Added ${environment} server reference for function: %s (method: %s, source: %s) in normalizedId=%s`, name, method || "default", source, normalizedId);
|
|
118
151
|
}
|
|
119
152
|
}
|
|
120
153
|
// Check for default export in the actual module (not re-exports)
|
|
121
154
|
if (hasDefaultExport(code, normalizedId)) {
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
let method;
|
|
156
|
+
let source = "action";
|
|
157
|
+
const patterns = [
|
|
158
|
+
`export default serverQuery($$$, { method: "$METHOD" })`,
|
|
159
|
+
`export default serverQuery($$$)`,
|
|
160
|
+
`export default serverAction($$$)`,
|
|
161
|
+
];
|
|
162
|
+
for (const pattern of patterns) {
|
|
163
|
+
const matches = root.root().findAll(pattern);
|
|
164
|
+
if (matches.length > 0) {
|
|
165
|
+
if (pattern.includes("serverQuery")) {
|
|
166
|
+
const methodMatch = matches[0].getMatch("METHOD");
|
|
167
|
+
method = methodMatch ? methodMatch.text() : "GET";
|
|
168
|
+
source = "query";
|
|
169
|
+
}
|
|
170
|
+
else if (pattern.includes("serverAction")) {
|
|
171
|
+
method = "POST";
|
|
172
|
+
source = "action";
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
let extraArgs = "";
|
|
178
|
+
if (source === "query") {
|
|
179
|
+
extraArgs = `, ${JSON.stringify(method ?? "GET")}, "query"`;
|
|
180
|
+
}
|
|
181
|
+
else if (method !== undefined) {
|
|
182
|
+
extraArgs = `, ${JSON.stringify(method)}`;
|
|
183
|
+
}
|
|
184
|
+
s.append(`\nexport default createServerReference(${JSON.stringify(normalizedId)}, "default"${extraArgs});\n`);
|
|
185
|
+
log(`Added ${environment} server reference for default export (method: %s, source: %s) in normalizedId=%s`, method || "default", source, normalizedId);
|
|
124
186
|
}
|
|
125
187
|
process.env.VERBOSE &&
|
|
126
188
|
log(`${environment} transformation complete for normalizedId=%s`, normalizedId);
|
|
@@ -89,6 +89,36 @@ export async function sum() {
|
|
|
89
89
|
export { sum } from './math';
|
|
90
90
|
export { default as multiply } from './multiply';
|
|
91
91
|
export * from './utils';
|
|
92
|
+
`;
|
|
93
|
+
let SERVER_QUERY_GET_CODE = `
|
|
94
|
+
"use server";
|
|
95
|
+
export const getProject = serverQuery(async (id) => {
|
|
96
|
+
return { id, name: "Project X" };
|
|
97
|
+
});
|
|
98
|
+
`;
|
|
99
|
+
let SERVER_QUERY_POST_CODE = `
|
|
100
|
+
"use server";
|
|
101
|
+
export const getProject = serverQuery(async (id) => {
|
|
102
|
+
return { id, name: "Project X" };
|
|
103
|
+
}, { method: "POST" });
|
|
104
|
+
`;
|
|
105
|
+
let SERVER_ACTION_CODE = `
|
|
106
|
+
"use server";
|
|
107
|
+
export const upvote = serverAction(async (id) => {
|
|
108
|
+
return { id, count: 1 };
|
|
109
|
+
});
|
|
110
|
+
`;
|
|
111
|
+
let SERVER_QUERY_DEFAULT_CODE = `
|
|
112
|
+
"use server";
|
|
113
|
+
export default serverQuery(async (id) => {
|
|
114
|
+
return { id, name: "Project X" };
|
|
115
|
+
});
|
|
116
|
+
`;
|
|
117
|
+
let SERVER_ACTION_DEFAULT_CODE = `
|
|
118
|
+
"use server";
|
|
119
|
+
export default serverAction(async (id) => {
|
|
120
|
+
return { id, name: "Project X" };
|
|
121
|
+
});
|
|
92
122
|
`;
|
|
93
123
|
const TEST_CASES = {
|
|
94
124
|
COMMENT_CODE,
|
|
@@ -102,6 +132,11 @@ export * from './utils';
|
|
|
102
132
|
RE_EXPORT_CODE,
|
|
103
133
|
PREDEFINED_DEFAULT_EXPORT_CODE,
|
|
104
134
|
EXPORT_DEFAULT_FUNCTION_CODE,
|
|
135
|
+
SERVER_QUERY_GET_CODE,
|
|
136
|
+
SERVER_QUERY_POST_CODE,
|
|
137
|
+
SERVER_ACTION_CODE,
|
|
138
|
+
SERVER_QUERY_DEFAULT_CODE,
|
|
139
|
+
SERVER_ACTION_DEFAULT_CODE,
|
|
105
140
|
};
|
|
106
141
|
describe("TRANSFORMS", () => {
|
|
107
142
|
for (const [key, CODE] of Object.entries(TEST_CASES)) {
|
|
@@ -3,9 +3,12 @@ export const virtualPlugin = (name, load) => {
|
|
|
3
3
|
name = "virtual:" + name;
|
|
4
4
|
return {
|
|
5
5
|
name: `rwsdk:virtual-${name}`,
|
|
6
|
-
resolveId(source, _importer,
|
|
7
|
-
// Skip during directive scanning to avoid performance issues
|
|
8
|
-
|
|
6
|
+
resolveId(source, _importer, options) {
|
|
7
|
+
// Skip during our directive scanning to avoid performance issues
|
|
8
|
+
// context(justinvdm, 20 Jan 2025): We check options.custom?.rwsdk?.directiveScan to distinguish
|
|
9
|
+
// between our directive scan (which should skip) and external calls like Cloudflare's early
|
|
10
|
+
// dispatch (which should be handled normally).
|
|
11
|
+
if (options?.custom?.rwsdk?.directiveScan === true) {
|
|
9
12
|
return;
|
|
10
13
|
}
|
|
11
14
|
if (source === name || source.startsWith(`${name}?`)) {
|
|
@@ -14,10 +17,6 @@ export const virtualPlugin = (name, load) => {
|
|
|
14
17
|
return;
|
|
15
18
|
},
|
|
16
19
|
load(id, options) {
|
|
17
|
-
// Skip during directive scanning to avoid performance issues
|
|
18
|
-
if (process.env.RWSDK_DIRECTIVE_SCAN_ACTIVE) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
20
|
if (id === `\0${name}` || id.startsWith(`\0${name}?`)) {
|
|
22
21
|
return load.apply(this, [id, options]);
|
|
23
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rwsdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.51",
|
|
4
4
|
"description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,15 +15,22 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc --build --clean && tsc",
|
|
18
|
+
"build:watch": "npm run build -- --watch",
|
|
18
19
|
"release": "./scripts/release.sh",
|
|
19
20
|
"test": "vitest --run",
|
|
21
|
+
"bench": "vitest bench --run",
|
|
22
|
+
"bench:baseline": "vitest bench --run --outputJson=benchmarks/router-bench-baseline.json",
|
|
23
|
+
"bench:compare": "vitest bench --run --compare=benchmarks/router-bench-baseline.json",
|
|
24
|
+
"test:e2e": "node scripts/test-e2e.mjs",
|
|
25
|
+
"setup:e2e": "pnpm setup:wrangler",
|
|
26
|
+
"setup:wrangler": "../../scripts/setup-wrangler-auth.sh",
|
|
20
27
|
"debug:sync": "tsx ./src/scripts/debug-sync.mts",
|
|
21
28
|
"smoke-test": "tsx ./src/scripts/smoke-test.mts"
|
|
22
29
|
},
|
|
23
30
|
"exports": {
|
|
24
31
|
"./vite": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
32
|
+
"types": "./dist/vite/index.d.mts",
|
|
33
|
+
"default": "./dist/vite/index.mjs"
|
|
27
34
|
},
|
|
28
35
|
"./worker": {
|
|
29
36
|
"react-server": "./dist/runtime/entries/worker.js",
|
|
@@ -36,6 +43,10 @@
|
|
|
36
43
|
"types": "./dist/runtime/entries/client.d.ts",
|
|
37
44
|
"default": "./dist/runtime/entries/client.js"
|
|
38
45
|
},
|
|
46
|
+
"./__state": {
|
|
47
|
+
"types": "./dist/runtime/state.d.ts",
|
|
48
|
+
"default": "./dist/runtime/state.js"
|
|
49
|
+
},
|
|
39
50
|
"./__ssr": {
|
|
40
51
|
"react-server": "./dist/runtime/entries/no-react-server.js",
|
|
41
52
|
"types": "./dist/runtime/entries/ssr.d.ts",
|
|
@@ -54,7 +65,8 @@
|
|
|
54
65
|
},
|
|
55
66
|
"./router": {
|
|
56
67
|
"types": "./dist/runtime/entries/router.d.ts",
|
|
57
|
-
"
|
|
68
|
+
"workerd": "./dist/runtime/entries/router.js",
|
|
69
|
+
"default": "./dist/runtime/entries/routerClient.js"
|
|
58
70
|
},
|
|
59
71
|
"./auth": {
|
|
60
72
|
"types": "./dist/runtime/entries/auth.d.ts",
|
|
@@ -99,6 +111,14 @@
|
|
|
99
111
|
"./realtime/durableObject": {
|
|
100
112
|
"types": "./dist/runtime/lib/realtime/durableObject.d.ts",
|
|
101
113
|
"default": "./dist/runtime/lib/realtime/durableObject.js"
|
|
114
|
+
},
|
|
115
|
+
"./use-synced-state/client": {
|
|
116
|
+
"types": "./dist/use-synced-state/client.d.ts",
|
|
117
|
+
"default": "./dist/use-synced-state/client.js"
|
|
118
|
+
},
|
|
119
|
+
"./use-synced-state/worker": {
|
|
120
|
+
"types": "./dist/use-synced-state/worker.d.mts",
|
|
121
|
+
"workerd": "./dist/use-synced-state/worker.mjs"
|
|
102
122
|
}
|
|
103
123
|
},
|
|
104
124
|
"keywords": [
|
|
@@ -134,62 +154,67 @@
|
|
|
134
154
|
"license": "MIT",
|
|
135
155
|
"dependencies": {
|
|
136
156
|
"@ast-grep/napi": "~0.39.0",
|
|
137
|
-
"@cloudflare/workers-types": "~4.
|
|
157
|
+
"@cloudflare/workers-types": "~4.20260124.0",
|
|
138
158
|
"@mdx-js/mdx": "~3.1.1",
|
|
139
159
|
"@puppeteer/browsers": "~2.10.0",
|
|
140
160
|
"@types/decompress": "~4.2.7",
|
|
141
161
|
"@types/fs-extra": "~11.0.4",
|
|
142
|
-
"@types/
|
|
143
|
-
"@types/react
|
|
162
|
+
"@types/glob": "^8.1.0",
|
|
163
|
+
"@types/react": "~19.2.9",
|
|
164
|
+
"@types/react-dom": "~19.2.3",
|
|
144
165
|
"@types/react-is": "~19.0.0",
|
|
145
166
|
"@vitejs/plugin-react": "~5.0.0",
|
|
146
167
|
"chokidar": "~4.0.0",
|
|
147
168
|
"debug": "~4.4.0",
|
|
169
|
+
"decompress": "~4.2.1",
|
|
148
170
|
"enhanced-resolve": "~5.18.1",
|
|
149
171
|
"eventsource-parser": "~3.0.0",
|
|
150
172
|
"execa": "~9.6.0",
|
|
151
173
|
"find-up": "~8.0.0",
|
|
152
174
|
"fs-extra": "~11.3.0",
|
|
153
|
-
"
|
|
175
|
+
"get-port": "^7.1.0",
|
|
176
|
+
"glob": "~11.1.0",
|
|
154
177
|
"ignore": "~7.0.4",
|
|
155
178
|
"jsonc-parser": "~3.3.1",
|
|
156
179
|
"kysely": "~0.28.2",
|
|
157
180
|
"kysely-do": "~0.0.1-rc.1",
|
|
158
|
-
"lodash": "~4.17.
|
|
181
|
+
"lodash": "~4.17.23",
|
|
159
182
|
"magic-string": "~0.30.17",
|
|
160
183
|
"picocolors": "~1.1.1",
|
|
161
184
|
"proper-lockfile": "~4.1.2",
|
|
162
185
|
"puppeteer-core": "~24.22.0",
|
|
163
186
|
"react-is": "~19.1.0",
|
|
164
187
|
"rsc-html-stream": "~0.0.6",
|
|
188
|
+
"server-only": "^0.0.1",
|
|
165
189
|
"tmp-promise": "~3.0.3",
|
|
166
190
|
"ts-morph": "~27.0.0",
|
|
167
191
|
"unique-names-generator": "~4.7.1",
|
|
168
192
|
"vibe-rules": "~0.3.0",
|
|
169
|
-
"vite-tsconfig-paths": "~5.1.4"
|
|
170
|
-
"decompress": "~4.2.1"
|
|
193
|
+
"vite-tsconfig-paths": "~5.1.4"
|
|
171
194
|
},
|
|
172
195
|
"peerDependencies": {
|
|
173
|
-
"@cloudflare/vite-plugin": "^1.
|
|
174
|
-
"
|
|
175
|
-
"react
|
|
176
|
-
"react-
|
|
196
|
+
"@cloudflare/vite-plugin": "^1.21.2",
|
|
197
|
+
"capnweb": "~0.2.0",
|
|
198
|
+
"react": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
|
|
199
|
+
"react-dom": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
|
|
200
|
+
"react-server-dom-webpack": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
|
|
177
201
|
"vite": "^6.2.6 || 7.x",
|
|
178
|
-
"wrangler": "^4.
|
|
202
|
+
"wrangler": "^4.60.0"
|
|
179
203
|
},
|
|
180
204
|
"packageManager": "pnpm@10.0.0+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b",
|
|
181
205
|
"devDependencies": {
|
|
182
|
-
"@cloudflare/vite-plugin": "1.
|
|
206
|
+
"@cloudflare/vite-plugin": "1.21.2",
|
|
207
|
+
"capnweb": "~0.2.0",
|
|
183
208
|
"@types/debug": "~4.1.12",
|
|
184
209
|
"@types/js-beautify": "~1.14.3",
|
|
185
210
|
"@types/lodash": "~4.17.16",
|
|
186
|
-
"@types/node": "~24.
|
|
211
|
+
"@types/node": "~24.10.0",
|
|
187
212
|
"@types/proper-lockfile": "~4.1.4",
|
|
188
213
|
"js-beautify": "~1.15.4",
|
|
189
214
|
"semver": "~7.7.1",
|
|
190
|
-
"tsx": "~4.
|
|
215
|
+
"tsx": "~4.21.0",
|
|
191
216
|
"typescript": "~5.9.0",
|
|
192
|
-
"vite": "7.1
|
|
217
|
+
"vite": "~7.3.1",
|
|
193
218
|
"vitest": "~3.2.0"
|
|
194
219
|
}
|
|
195
220
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import debug from "debug";
|
|
2
|
-
const log = debug("rwsdk:vite:manifest-plugin");
|
|
3
|
-
const virtualModuleId = "virtual:rwsdk:manifest.js";
|
|
4
|
-
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
5
|
-
export const manifestPlugin = ({ projectRootDir, }) => {
|
|
6
|
-
let isBuild = false;
|
|
7
|
-
return {
|
|
8
|
-
name: "rwsdk:vite:manifest-plugin",
|
|
9
|
-
enforce: "pre",
|
|
10
|
-
configResolved(config) {
|
|
11
|
-
isBuild = config.command === "build";
|
|
12
|
-
},
|
|
13
|
-
resolveId(id) {
|
|
14
|
-
// Skip during directive scanning to avoid performance issues
|
|
15
|
-
if (process.env.RWSDK_DIRECTIVE_SCAN_ACTIVE) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (id === virtualModuleId) {
|
|
19
|
-
return resolvedVirtualModuleId;
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
async load(id) {
|
|
23
|
-
// Skip during directive scanning to avoid performance issues
|
|
24
|
-
if (process.env.RWSDK_DIRECTIVE_SCAN_ACTIVE) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (id === resolvedVirtualModuleId) {
|
|
28
|
-
if (isBuild) {
|
|
29
|
-
// context(justinvdm, 28 Aug 2025): During the build, we don't have
|
|
30
|
-
// the manifest yet. We insert a placeholder that the linker plugin
|
|
31
|
-
// will replace in the final phase.
|
|
32
|
-
log("Returning manifest placeholder for build");
|
|
33
|
-
return `export default "__RWSDK_MANIFEST_PLACEHOLDER__"`;
|
|
34
|
-
}
|
|
35
|
-
// In dev, we can return an empty object.
|
|
36
|
-
log("Not a build, returning empty manifest");
|
|
37
|
-
return `export default {}`;
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
configEnvironment(name, config) {
|
|
41
|
-
if (name !== "worker" && name !== "ssr") {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
log("Configuring environment: name=%s", name);
|
|
45
|
-
config.optimizeDeps ??= {};
|
|
46
|
-
config.optimizeDeps.esbuildOptions ??= {};
|
|
47
|
-
config.optimizeDeps.esbuildOptions.plugins ??= [];
|
|
48
|
-
config.optimizeDeps.esbuildOptions.plugins.push({
|
|
49
|
-
name: "rwsdk:manifest:esbuild",
|
|
50
|
-
setup(build) {
|
|
51
|
-
log("Setting up esbuild plugin for environment: %s", name);
|
|
52
|
-
build.onResolve({ filter: /^virtual:rwsdk:manifest\.js$/ }, () => {
|
|
53
|
-
log("Resolving virtual manifest module in esbuild");
|
|
54
|
-
return {
|
|
55
|
-
path: "virtual:rwsdk:manifest.js",
|
|
56
|
-
external: true,
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|
|
File without changes
|