rwsdk 1.0.0-beta.56 → 1.0.0-beta.58

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.
@@ -29,6 +29,11 @@ if (typeof window !== "undefined") {
29
29
  * @returns RPC client instance.
30
30
  */
31
31
  export const getSyncedStateClient = (endpoint = DEFAULT_SYNCED_STATE_PATH) => {
32
+ // Convert relative endpoint to absolute URL for environments like WKWebView
33
+ if (endpoint.startsWith("/") && typeof window !== "undefined") {
34
+ const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
35
+ endpoint = `${protocol}//${window.location.host}${endpoint}`;
36
+ }
32
37
  // Return existing client if already cached for this endpoint
33
38
  const existingClient = clientCache.get(endpoint);
34
39
  if (existingClient) {
@@ -1,4 +1,5 @@
1
1
  import type { ViteBuilder } from "vite";
2
+ import { ConfigurableEsbuildOptions } from "./runDirectivesScan.mjs";
2
3
  /**
3
4
  * The build orchestrator is responsible for running the multi-phase build
4
5
  * process for production. It is designed to solve the circular dependency
@@ -6,11 +7,12 @@ import type { ViteBuilder } from "vite";
6
7
  *
7
8
  * @see docs/architecture/productionBuildProcess.md
8
9
  */
9
- export declare function buildApp({ builder, clientEntryPoints, clientFiles, serverFiles, projectRootDir, workerEntryPathname, }: {
10
+ export declare function buildApp({ builder, clientEntryPoints, clientFiles, serverFiles, projectRootDir, workerEntryPathname, esbuildOptions, }: {
10
11
  builder: ViteBuilder;
11
12
  clientEntryPoints: Set<string>;
12
13
  clientFiles: Set<string>;
13
14
  serverFiles: Set<string>;
14
15
  projectRootDir: string;
15
16
  workerEntryPathname: string;
17
+ esbuildOptions: ConfigurableEsbuildOptions;
16
18
  }): Promise<void>;
@@ -12,7 +12,7 @@ const log = debug("rwsdk:vite:build-app");
12
12
  *
13
13
  * @see docs/architecture/productionBuildProcess.md
14
14
  */
15
- export async function buildApp({ builder, clientEntryPoints, clientFiles, serverFiles, projectRootDir, workerEntryPathname, }) {
15
+ export async function buildApp({ builder, clientEntryPoints, clientFiles, serverFiles, projectRootDir, workerEntryPathname, esbuildOptions, }) {
16
16
  await rm(resolve(projectRootDir, "dist"), { recursive: true, force: true });
17
17
  const workerEnv = builder.environments.worker;
18
18
  // Run a pre-scan build pass to allow plugins to set up and generate code
@@ -49,6 +49,7 @@ export async function buildApp({ builder, clientEntryPoints, clientFiles, server
49
49
  clientFiles,
50
50
  serverFiles,
51
51
  entries: [workerEntryPathname],
52
+ esbuildOptions,
52
53
  });
53
54
  console.log("Building worker...");
54
55
  process.env.RWSDK_BUILD_PASS = "worker";
@@ -1,9 +1,11 @@
1
1
  import { Plugin } from "vite";
2
- export declare const configPlugin: ({ silent, projectRootDir, workerEntryPathname, clientFiles, serverFiles, clientEntryPoints, }: {
2
+ import { ConfigurableEsbuildOptions } from "./runDirectivesScan.mjs";
3
+ export declare const configPlugin: ({ silent, projectRootDir, workerEntryPathname, clientFiles, serverFiles, clientEntryPoints, esbuildOptions, }: {
3
4
  silent: boolean;
4
5
  projectRootDir: string;
5
6
  workerEntryPathname: string;
6
7
  clientFiles: Set<string>;
7
8
  serverFiles: Set<string>;
8
9
  clientEntryPoints: Set<string>;
10
+ esbuildOptions: ConfigurableEsbuildOptions;
9
11
  }) => Plugin;
@@ -4,7 +4,7 @@ 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 configPlugin = ({ silent, projectRootDir, workerEntryPathname, clientFiles, serverFiles, clientEntryPoints, }) => ({
7
+ export const configPlugin = ({ silent, projectRootDir, workerEntryPathname, clientFiles, serverFiles, clientEntryPoints, esbuildOptions, }) => ({
8
8
  name: "rwsdk:config",
9
9
  config: async (_, { command }) => {
10
10
  const mode = process.env.NODE_ENV;
@@ -189,6 +189,7 @@ export const configPlugin = ({ silent, projectRootDir, workerEntryPathname, clie
189
189
  clientFiles,
190
190
  serverFiles,
191
191
  workerEntryPathname,
192
+ esbuildOptions,
192
193
  });
193
194
  },
194
195
  },
@@ -1,9 +1,11 @@
1
1
  import { Plugin } from "vite";
2
+ import { ConfigurableEsbuildOptions } from "./runDirectivesScan.mjs";
2
3
  export declare const generateVendorBarrelContent: (files: Set<string>, projectRootDir: string) => string;
3
4
  export declare const generateAppBarrelContent: (files: Set<string>, projectRootDir: string) => string;
4
- export declare const directiveModulesDevPlugin: ({ clientFiles, serverFiles, projectRootDir, workerEntryPathname, }: {
5
+ export declare const directiveModulesDevPlugin: ({ clientFiles, serverFiles, projectRootDir, workerEntryPathname, esbuildOptions, }: {
5
6
  clientFiles: Set<string>;
6
7
  serverFiles: Set<string>;
7
8
  projectRootDir: string;
8
9
  workerEntryPathname: string;
10
+ esbuildOptions: ConfigurableEsbuildOptions;
9
11
  }) => Plugin;
@@ -30,7 +30,7 @@ export const generateAppBarrelContent = (files, projectRootDir) => {
30
30
  })
31
31
  .join("\n");
32
32
  };
33
- export const directiveModulesDevPlugin = ({ clientFiles, serverFiles, projectRootDir, workerEntryPathname, }) => {
33
+ export const directiveModulesDevPlugin = ({ clientFiles, serverFiles, projectRootDir, workerEntryPathname, esbuildOptions, }) => {
34
34
  const { promise: scanPromise, resolve: resolveScanPromise } = Promise.withResolvers();
35
35
  const tempDir = mkdtempSync(path.join(os.tmpdir(), "rwsdk-"));
36
36
  const APP_CLIENT_BARREL_PATH = path.join(tempDir, "app-client-barrel.js");
@@ -56,6 +56,7 @@ export const directiveModulesDevPlugin = ({ clientFiles, serverFiles, projectRoo
56
56
  clientFiles,
57
57
  serverFiles,
58
58
  entries: [workerEntryPathname],
59
+ esbuildOptions,
59
60
  }).then(() => {
60
61
  // context(justinvdm, 11 Sep 2025): For vendor barrels, we write the
61
62
  // files directly to disk after the scan. For app barrels, we use a
@@ -1,5 +1,6 @@
1
1
  import { InlineConfig } from "vite";
2
2
  import { unstable_readConfig } from "wrangler";
3
+ import { ConfigurableEsbuildOptions } from "./runDirectivesScan.mjs";
3
4
  export type RedwoodPluginOptions = {
4
5
  silent?: boolean;
5
6
  rootDir?: string;
@@ -11,6 +12,7 @@ export type RedwoodPluginOptions = {
11
12
  entry?: {
12
13
  worker?: string;
13
14
  };
15
+ esbuildOptions?: ConfigurableEsbuildOptions;
14
16
  };
15
17
  export declare const determineWorkerEntryPathname: ({ projectRootDir, workerConfigPath, options, readConfig, }: {
16
18
  projectRootDir: string;
@@ -42,6 +42,7 @@ const serverFiles = new Set();
42
42
  const clientEntryPoints = new Set();
43
43
  export const redwoodPlugin = async (options = {}) => {
44
44
  const projectRootDir = process.cwd();
45
+ const esbuildOptions = options.esbuildOptions ?? {};
45
46
  if (options.forceClientPaths) {
46
47
  const clientPaths = await resolveForcedPaths({
47
48
  patterns: options.forceClientPaths,
@@ -92,6 +93,7 @@ export const redwoodPlugin = async (options = {}) => {
92
93
  serverFiles,
93
94
  projectRootDir,
94
95
  workerEntryPathname,
96
+ esbuildOptions,
95
97
  }),
96
98
  configPlugin({
97
99
  silent: options.silent ?? false,
@@ -100,6 +102,7 @@ export const redwoodPlugin = async (options = {}) => {
100
102
  clientFiles,
101
103
  serverFiles,
102
104
  clientEntryPoints,
105
+ esbuildOptions,
103
106
  }),
104
107
  ssrBridgePlugin({
105
108
  clientFiles,
@@ -1,4 +1,5 @@
1
1
  import { Environment, ResolvedConfig } from "vite";
2
+ export type ConfigurableEsbuildOptions = Record<string, unknown>;
2
3
  type Resolver = (context: {}, path: string, request: string, resolveContext: {}, callback: (err: Error | null, result?: string | false) => void) => void;
3
4
  export declare function resolveModuleWithEnvironment({ path, importer, importerEnv, clientResolver, workerResolver, }: {
4
5
  path: string;
@@ -18,11 +19,12 @@ export declare function classifyModule({ contents, inheritedEnv, }: {
18
19
  isServer: boolean;
19
20
  };
20
21
  export type EsbuildLoader = "js" | "jsx" | "ts" | "tsx" | "default";
21
- export declare const runDirectivesScan: ({ rootConfig, environments, clientFiles, serverFiles, entries: initialEntries, }: {
22
+ export declare const runDirectivesScan: ({ rootConfig, environments, clientFiles, serverFiles, entries: initialEntries, esbuildOptions, }: {
22
23
  rootConfig: ResolvedConfig;
23
24
  environments: Record<string, Environment>;
24
25
  clientFiles: Set<string>;
25
26
  serverFiles: Set<string>;
26
27
  entries?: string[];
28
+ esbuildOptions: ConfigurableEsbuildOptions;
27
29
  }) => Promise<void>;
28
30
  export {};
@@ -85,7 +85,7 @@ export function classifyModule({ contents, inheritedEnv, }) {
85
85
  }
86
86
  return { moduleEnv, isClient, isServer };
87
87
  }
88
- export const runDirectivesScan = async ({ rootConfig, environments, clientFiles, serverFiles, entries: initialEntries, }) => {
88
+ export const runDirectivesScan = async ({ rootConfig, environments, clientFiles, serverFiles, entries: initialEntries, esbuildOptions, }) => {
89
89
  deferredLog("\n… (rwsdk) Scanning for 'use client' and 'use server' directives...");
90
90
  try {
91
91
  const fileContentCache = new Map();
@@ -287,6 +287,7 @@ export const runDirectivesScan = async ({ rootConfig, environments, clientFiles,
287
287
  },
288
288
  };
289
289
  await esbuild.build({
290
+ ...esbuildOptions,
290
291
  entryPoints: Array.from(combinedEntries),
291
292
  bundle: true,
292
293
  write: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "1.0.0-beta.56",
3
+ "version": "1.0.0-beta.58",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {
@@ -154,7 +154,7 @@
154
154
  "license": "MIT",
155
155
  "dependencies": {
156
156
  "@ast-grep/napi": "~0.41.0",
157
- "@cloudflare/workers-types": "~4.20260305.1",
157
+ "@cloudflare/workers-types": "~4.20260307.1",
158
158
  "@mdx-js/mdx": "~3.1.1",
159
159
  "@puppeteer/browsers": "~2.13.0",
160
160
  "@types/decompress": "~4.2.7",
@@ -193,22 +193,22 @@
193
193
  "vite-tsconfig-paths": "~6.1.1"
194
194
  },
195
195
  "peerDependencies": {
196
- "@cloudflare/vite-plugin": "^1.26.0",
196
+ "@cloudflare/vite-plugin": "^1.26.1",
197
197
  "capnweb": "~0.5.0",
198
198
  "react": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
199
199
  "react-dom": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
200
200
  "react-server-dom-webpack": ">=19.2.0-0 <19.3.0 || >=19.3.0-0 <20.0.0",
201
201
  "vite": "^6.2.6 || 7.x",
202
- "wrangler": "^4.70.0"
202
+ "wrangler": "^4.71.0"
203
203
  },
204
- "packageManager": "pnpm@10.28.2",
204
+ "packageManager": "pnpm@10.31.0",
205
205
  "devDependencies": {
206
- "@cloudflare/vite-plugin": "1.26.0",
206
+ "@cloudflare/vite-plugin": "1.26.1",
207
207
  "capnweb": "~0.5.0",
208
208
  "@types/debug": "~4.1.12",
209
209
  "@types/js-beautify": "~1.14.3",
210
210
  "@types/lodash": "~4.17.24",
211
- "@types/node": "~25.3.3",
211
+ "@types/node": "~25.3.5",
212
212
  "@types/proper-lockfile": "~4.1.4",
213
213
  "js-beautify": "~1.15.4",
214
214
  "semver": "~7.7.4",