rwsdk 1.5.2 → 1.5.4

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.
@@ -13,6 +13,12 @@ export class SyncedStateIdentityError extends Error {
13
13
  // We validate serializability and size here so a bad extractor fails the
14
14
  // handshake with a clear error instead of an opaque internal failure.
15
15
  export function setIdentityInUrl(identity, url) {
16
+ // context(justinvdm, 29 Jun 2026): No identity extractor was registered, so
17
+ // nothing needs to be passed to the DO. Skip setting the query param;
18
+ // getIdentityFromUrl already returns undefined when it is missing.
19
+ if (identity === undefined) {
20
+ return url;
21
+ }
16
22
  let serialized;
17
23
  try {
18
24
  serialized = JSON.stringify(identity);
@@ -1,5 +1,8 @@
1
1
  import { Plugin } from "vite";
2
2
  import { ConfigurableEsbuildOptions } from "./runDirectivesScan.mjs";
3
+ export declare const SSR_BRIDGE_ROLLDOWN_EXPERIMENTAL: {
4
+ lazyBarrel: boolean;
5
+ };
3
6
  export declare const configPlugin: ({ silent, projectRootDir, workerEntryPathname, clientFiles, serverFiles, clientEntryPoints, esbuildOptions, }: {
4
7
  silent: boolean;
5
8
  projectRootDir: string;
@@ -4,6 +4,16 @@ import { INTERMEDIATE_SSR_BRIDGE_PATH } from "../lib/constants.mjs";
4
4
  import { buildApp } from "./buildApp.mjs";
5
5
  import { externalModules } from "./constants.mjs";
6
6
  import { ssrBridgeWrapPlugin } from "./ssrBridgeWrapPlugin.mjs";
7
+ export const SSR_BRIDGE_ROLLDOWN_EXPERIMENTAL = {
8
+ // Rolldown's lazy barrel optimization can keep code that references imports it
9
+ // already pruned when `codeSplitting` is false. The SSR bridge intentionally
10
+ // disables code splitting, so keep lazy barrel off for this build until the
11
+ // upstream issue is fixed.
12
+ // See:
13
+ // - https://github.com/rolldown/rolldown/issues/9691#issuecomment-4666238497
14
+ // - https://github.com/rolldown/rolldown/issues/9964
15
+ lazyBarrel: false,
16
+ };
7
17
  export const configPlugin = ({ silent, projectRootDir, workerEntryPathname, clientFiles, serverFiles, clientEntryPoints, esbuildOptions, }) => ({
8
18
  name: "rwsdk:config",
9
19
  enforce: "pre",
@@ -173,6 +183,7 @@ export const configPlugin = ({ silent, projectRootDir, workerEntryPathname, clie
173
183
  },
174
184
  outDir: path.dirname(INTERMEDIATE_SSR_BRIDGE_PATH),
175
185
  rolldownOptions: {
186
+ experimental: SSR_BRIDGE_ROLLDOWN_EXPERIMENTAL,
176
187
  output: {
177
188
  // context(justinvdm, 15 Sep 2025): The SSR bundle is a
178
189
  // pre-compiled artifact. When the linker pass bundles it into
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,73 @@
1
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ import { build } from "vite";
6
+ import { describe, expect, it } from "vitest";
7
+ import { SSR_BRIDGE_ROLLDOWN_EXPERIMENTAL } from "./configPlugin.mjs";
8
+ describe("SSR bridge Rolldown options", () => {
9
+ it("keeps side-effect-free barrels valid when code splitting is disabled", async () => {
10
+ const root = await mkdtemp(path.join(tmpdir(), "rwsdk-ssr-bridge-lazy-barrel-"));
11
+ try {
12
+ await mkdir(path.join(root, "src", "lib"), { recursive: true });
13
+ await writeFile(path.join(root, "package.json"), JSON.stringify({ type: "module", private: true, sideEffects: false }));
14
+ await writeFile(path.join(root, "src", "lib", "eg.js"), `const primitives = { string: { tag: "s" }, number: { tag: "n" } };
15
+ const higher = { object: (shape) => ({ tag: "o", shape, parse: () => true }) };
16
+ export const eg = { ...primitives, ...higher };
17
+ `);
18
+ await writeFile(path.join(root, "src", "lib", "account.js"), `import { eg } from "./eg.js";
19
+ export const AccountSettings = eg.object({ a: eg.string, n: eg.number });
20
+ export const AccountMeta = eg.object({ b: eg.string });
21
+ `);
22
+ await writeFile(path.join(root, "src", "lib", "index.js"), `export * from "./account.js";
23
+ export const objectKeys = (o) => Object.keys(o);
24
+ `);
25
+ await writeFile(path.join(root, "src", "story.js"), `import { objectKeys } from "./lib/index.js";
26
+ export const run = () => (objectKeys ? "ok" : "no");
27
+ `);
28
+ await writeFile(path.join(root, "src", "entry.cjs"), `const { run } = require("./story.js");
29
+ console.log(run());
30
+ `);
31
+ await build({
32
+ configFile: false,
33
+ root,
34
+ logLevel: "silent",
35
+ build: {
36
+ ssr: true,
37
+ minify: true,
38
+ outDir: path.join(root, "dist"),
39
+ emptyOutDir: true,
40
+ lib: {
41
+ entry: {
42
+ index: path.join(root, "src", "entry.cjs"),
43
+ },
44
+ formats: ["es"],
45
+ fileName: () => "index.js",
46
+ },
47
+ rolldownOptions: {
48
+ experimental: SSR_BRIDGE_ROLLDOWN_EXPERIMENTAL,
49
+ output: {
50
+ codeSplitting: false,
51
+ },
52
+ },
53
+ },
54
+ });
55
+ const outputPath = path.join(root, "dist", "index.js");
56
+ const logs = [];
57
+ const originalLog = console.log;
58
+ console.log = (...args) => {
59
+ logs.push(args.join(" "));
60
+ };
61
+ try {
62
+ await import(pathToFileURL(outputPath).href);
63
+ }
64
+ finally {
65
+ console.log = originalLog;
66
+ }
67
+ expect(logs).toContain("ok");
68
+ }
69
+ finally {
70
+ await rm(root, { recursive: true, force: true });
71
+ }
72
+ });
73
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {