rwsdk 1.0.0-beta.5 → 1.0.0-beta.50
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 +41 -19
- 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.50",
|
|
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,19 @@
|
|
|
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",
|
|
20
24
|
"debug:sync": "tsx ./src/scripts/debug-sync.mts",
|
|
21
25
|
"smoke-test": "tsx ./src/scripts/smoke-test.mts"
|
|
22
26
|
},
|
|
23
27
|
"exports": {
|
|
24
28
|
"./vite": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
29
|
+
"types": "./dist/vite/index.d.mts",
|
|
30
|
+
"default": "./dist/vite/index.mjs"
|
|
27
31
|
},
|
|
28
32
|
"./worker": {
|
|
29
33
|
"react-server": "./dist/runtime/entries/worker.js",
|
|
@@ -36,6 +40,10 @@
|
|
|
36
40
|
"types": "./dist/runtime/entries/client.d.ts",
|
|
37
41
|
"default": "./dist/runtime/entries/client.js"
|
|
38
42
|
},
|
|
43
|
+
"./__state": {
|
|
44
|
+
"types": "./dist/runtime/state.d.ts",
|
|
45
|
+
"default": "./dist/runtime/state.js"
|
|
46
|
+
},
|
|
39
47
|
"./__ssr": {
|
|
40
48
|
"react-server": "./dist/runtime/entries/no-react-server.js",
|
|
41
49
|
"types": "./dist/runtime/entries/ssr.d.ts",
|
|
@@ -54,7 +62,8 @@
|
|
|
54
62
|
},
|
|
55
63
|
"./router": {
|
|
56
64
|
"types": "./dist/runtime/entries/router.d.ts",
|
|
57
|
-
"
|
|
65
|
+
"workerd": "./dist/runtime/entries/router.js",
|
|
66
|
+
"default": "./dist/runtime/entries/routerClient.js"
|
|
58
67
|
},
|
|
59
68
|
"./auth": {
|
|
60
69
|
"types": "./dist/runtime/entries/auth.d.ts",
|
|
@@ -99,6 +108,14 @@
|
|
|
99
108
|
"./realtime/durableObject": {
|
|
100
109
|
"types": "./dist/runtime/lib/realtime/durableObject.d.ts",
|
|
101
110
|
"default": "./dist/runtime/lib/realtime/durableObject.js"
|
|
111
|
+
},
|
|
112
|
+
"./use-synced-state/client": {
|
|
113
|
+
"types": "./dist/use-synced-state/client.d.ts",
|
|
114
|
+
"default": "./dist/use-synced-state/client.js"
|
|
115
|
+
},
|
|
116
|
+
"./use-synced-state/worker": {
|
|
117
|
+
"types": "./dist/use-synced-state/worker.d.mts",
|
|
118
|
+
"workerd": "./dist/use-synced-state/worker.mjs"
|
|
102
119
|
}
|
|
103
120
|
},
|
|
104
121
|
"keywords": [
|
|
@@ -134,62 +151,67 @@
|
|
|
134
151
|
"license": "MIT",
|
|
135
152
|
"dependencies": {
|
|
136
153
|
"@ast-grep/napi": "~0.39.0",
|
|
137
|
-
"@cloudflare/workers-types": "~4.
|
|
154
|
+
"@cloudflare/workers-types": "~4.20260122.0",
|
|
138
155
|
"@mdx-js/mdx": "~3.1.1",
|
|
139
156
|
"@puppeteer/browsers": "~2.10.0",
|
|
140
157
|
"@types/decompress": "~4.2.7",
|
|
141
158
|
"@types/fs-extra": "~11.0.4",
|
|
142
|
-
"@types/
|
|
143
|
-
"@types/react
|
|
159
|
+
"@types/glob": "^8.1.0",
|
|
160
|
+
"@types/react": "~19.2.7",
|
|
161
|
+
"@types/react-dom": "~19.2.3",
|
|
144
162
|
"@types/react-is": "~19.0.0",
|
|
145
163
|
"@vitejs/plugin-react": "~5.0.0",
|
|
146
164
|
"chokidar": "~4.0.0",
|
|
147
165
|
"debug": "~4.4.0",
|
|
166
|
+
"decompress": "~4.2.1",
|
|
148
167
|
"enhanced-resolve": "~5.18.1",
|
|
149
168
|
"eventsource-parser": "~3.0.0",
|
|
150
169
|
"execa": "~9.6.0",
|
|
151
170
|
"find-up": "~8.0.0",
|
|
152
171
|
"fs-extra": "~11.3.0",
|
|
153
|
-
"
|
|
172
|
+
"get-port": "^7.1.0",
|
|
173
|
+
"glob": "~11.1.0",
|
|
154
174
|
"ignore": "~7.0.4",
|
|
155
175
|
"jsonc-parser": "~3.3.1",
|
|
156
176
|
"kysely": "~0.28.2",
|
|
157
177
|
"kysely-do": "~0.0.1-rc.1",
|
|
158
|
-
"lodash": "~4.17.
|
|
178
|
+
"lodash": "~4.17.23",
|
|
159
179
|
"magic-string": "~0.30.17",
|
|
160
180
|
"picocolors": "~1.1.1",
|
|
161
181
|
"proper-lockfile": "~4.1.2",
|
|
162
182
|
"puppeteer-core": "~24.22.0",
|
|
163
183
|
"react-is": "~19.1.0",
|
|
164
184
|
"rsc-html-stream": "~0.0.6",
|
|
185
|
+
"server-only": "^0.0.1",
|
|
165
186
|
"tmp-promise": "~3.0.3",
|
|
166
187
|
"ts-morph": "~27.0.0",
|
|
167
188
|
"unique-names-generator": "~4.7.1",
|
|
168
189
|
"vibe-rules": "~0.3.0",
|
|
169
|
-
"vite-tsconfig-paths": "~5.1.4"
|
|
170
|
-
"decompress": "~4.2.1"
|
|
190
|
+
"vite-tsconfig-paths": "~5.1.4"
|
|
171
191
|
},
|
|
172
192
|
"peerDependencies": {
|
|
173
|
-
"@cloudflare/vite-plugin": "^1.
|
|
174
|
-
"
|
|
175
|
-
"react
|
|
176
|
-
"react-
|
|
193
|
+
"@cloudflare/vite-plugin": "^1.13.10",
|
|
194
|
+
"capnweb": "~0.2.0",
|
|
195
|
+
"react": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
|
|
196
|
+
"react-dom": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
|
|
197
|
+
"react-server-dom-webpack": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
|
|
177
198
|
"vite": "^6.2.6 || 7.x",
|
|
178
199
|
"wrangler": "^4.35.0"
|
|
179
200
|
},
|
|
180
201
|
"packageManager": "pnpm@10.0.0+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b",
|
|
181
202
|
"devDependencies": {
|
|
182
|
-
"@cloudflare/vite-plugin": "1.
|
|
203
|
+
"@cloudflare/vite-plugin": "1.21.2",
|
|
204
|
+
"capnweb": "~0.2.0",
|
|
183
205
|
"@types/debug": "~4.1.12",
|
|
184
206
|
"@types/js-beautify": "~1.14.3",
|
|
185
207
|
"@types/lodash": "~4.17.16",
|
|
186
|
-
"@types/node": "~24.
|
|
208
|
+
"@types/node": "~24.10.0",
|
|
187
209
|
"@types/proper-lockfile": "~4.1.4",
|
|
188
210
|
"js-beautify": "~1.15.4",
|
|
189
211
|
"semver": "~7.7.1",
|
|
190
|
-
"tsx": "~4.
|
|
212
|
+
"tsx": "~4.21.0",
|
|
191
213
|
"typescript": "~5.9.0",
|
|
192
|
-
"vite": "7.
|
|
214
|
+
"vite": "~7.3.0",
|
|
193
215
|
"vitest": "~3.2.0"
|
|
194
216
|
}
|
|
195
217
|
}
|
|
@@ -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
|