rwsdk 0.2.0-alpha.5 → 0.2.0-alpha.6-test.20250806100800

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.
@@ -8,7 +8,7 @@ import puppeteer from "puppeteer-core";
8
8
  import { takeScreenshot } from "./artifacts.mjs";
9
9
  import { RETRIES } from "./constants.mjs";
10
10
  import { $ } from "../$.mjs";
11
- import { fail } from "./utils.mjs";
11
+ import { fail, withRetries } from "./utils.mjs";
12
12
  import { reportSmokeTestResult } from "./reporting.mjs";
13
13
  import { updateTestStatus } from "./state.mjs";
14
14
  import * as fs from "fs/promises";
@@ -404,7 +404,7 @@ export async function checkUrlSmoke(page, url, isRealtime, bail = false, skipCli
404
404
  ? "realtimeClientModuleStyles"
405
405
  : "initialClientModuleStyles";
406
406
  try {
407
- await checkUrlStyles(page, "red");
407
+ await withRetries(() => checkUrlStyles(page, "red"), "URL styles check");
408
408
  updateTestStatus(env, urlStylesKey, "PASSED");
409
409
  log(`${phase} URL styles check passed`);
410
410
  }
@@ -420,7 +420,7 @@ export async function checkUrlSmoke(page, url, isRealtime, bail = false, skipCli
420
420
  }
421
421
  }
422
422
  try {
423
- await checkClientModuleStyles(page, "blue");
423
+ await withRetries(() => checkClientModuleStyles(page, "blue"), "Client module styles check");
424
424
  updateTestStatus(env, clientModuleStylesKey, "PASSED");
425
425
  log(`${phase} client module styles check passed`);
426
426
  }
@@ -507,7 +507,14 @@ export async function checkUrlSmoke(page, url, isRealtime, bail = false, skipCli
507
507
  await testClientComponentHmr(page, targetDir, phase, environment, bail);
508
508
  // Test style HMR if style tests aren't skipped
509
509
  if (!skipStyleTests) {
510
- await testStyleHMR(page, targetDir);
510
+ await withRetries(() => testStyleHMR(page, targetDir), "Style HMR test", async () => {
511
+ // This logic runs before each retry of testStyleHMR
512
+ const urlStylePath = join(targetDir, "src", "app", "smokeTestUrlStyles.css");
513
+ const clientStylePath = join(targetDir, "src", "app", "components", "smokeTestClientStyles.module.css");
514
+ // Restore original styles before re-running HMR test
515
+ await fs.writeFile(urlStylePath, urlStylesTemplate);
516
+ await fs.writeFile(clientStylePath, clientStylesTemplate);
517
+ });
511
518
  }
512
519
  else {
513
520
  log("Skipping style HMR test as requested");
@@ -1182,9 +1189,9 @@ async function testStyleHMR(page, targetDir) {
1182
1189
  // Allow time for HMR to kick in
1183
1190
  await new Promise((resolve) => setTimeout(resolve, 5000));
1184
1191
  // Check URL-based stylesheet HMR
1185
- await checkUrlStyles(page, "green");
1192
+ await withRetries(() => checkUrlStyles(page, "green"), "URL styles HMR check");
1186
1193
  // Check client-module stylesheet HMR
1187
- await checkClientModuleStyles(page, "green");
1194
+ await withRetries(() => checkClientModuleStyles(page, "green"), "Client module styles HMR check");
1188
1195
  // Restore original styles
1189
1196
  await fs.writeFile(urlStylePath, urlStylesTemplate);
1190
1197
  await fs.writeFile(clientStylePath, clientStylesTemplate);
@@ -13,3 +13,12 @@ export declare function teardown(): Promise<void>;
13
13
  * Formats the path suffix from a custom path
14
14
  */
15
15
  export declare function formatPathSuffix(customPath?: string): string;
16
+ /**
17
+ * Wraps an async function with retry logic.
18
+ * @param fn The async function to execute.
19
+ * @param description A description of the operation for logging.
20
+ * @param beforeRetry A function to run before each retry attempt.
21
+ * @param maxRetries The maximum number of retries.
22
+ * @param delay The delay between retries in milliseconds.
23
+ */
24
+ export declare function withRetries<T>(fn: () => Promise<T>, description: string, beforeRetry?: () => Promise<void>, maxRetries?: number, delay?: number): Promise<T>;
@@ -145,3 +145,32 @@ export function formatPathSuffix(customPath) {
145
145
  log("Formatted path suffix: %s", suffix);
146
146
  return suffix;
147
147
  }
148
+ /**
149
+ * Wraps an async function with retry logic.
150
+ * @param fn The async function to execute.
151
+ * @param description A description of the operation for logging.
152
+ * @param beforeRetry A function to run before each retry attempt.
153
+ * @param maxRetries The maximum number of retries.
154
+ * @param delay The delay between retries in milliseconds.
155
+ */
156
+ export async function withRetries(fn, description, beforeRetry, maxRetries = 5, delay = 2000) {
157
+ for (let i = 0; i < maxRetries; i++) {
158
+ try {
159
+ if (i > 0 && beforeRetry) {
160
+ log(`Running beforeRetry hook for "${description}"`);
161
+ await beforeRetry();
162
+ }
163
+ return await fn();
164
+ }
165
+ catch (error) {
166
+ log(`Attempt ${i + 1} of ${maxRetries} failed for "${description}": ${error instanceof Error ? error.message : String(error)}`);
167
+ if (i === maxRetries - 1) {
168
+ log(`All ${maxRetries} retries failed for "${description}".`);
169
+ throw error;
170
+ }
171
+ log(`Retrying in ${delay}ms...`);
172
+ await setTimeout(delay);
173
+ }
174
+ }
175
+ throw new Error("Retry loop failed unexpectedly.");
176
+ }
@@ -1,6 +1,7 @@
1
1
  import { Kysely } from "kysely";
2
- import { requestInfo, waitForRequestInfo } from "../../requestInfo/worker.js";
2
+ import { requestInfo } from "../../requestInfo/worker.js";
3
3
  import { DOWorkerDialect } from "./DOWorkerDialect.js";
4
+ const moduleLevelDbCache = new Map();
4
5
  const createDurableObjectDb = (durableObjectBinding, name = "main") => {
5
6
  const durableObjectId = durableObjectBinding.idFromName(name);
6
7
  const stub = durableObjectBinding.get(durableObjectId);
@@ -10,26 +11,41 @@ const createDurableObjectDb = (durableObjectBinding, name = "main") => {
10
11
  });
11
12
  };
12
13
  export function createDb(durableObjectBinding, name = "main") {
13
- const cacheKey = `${durableObjectBinding}_${name}`;
14
- const doCreateDb = () => {
15
- if (!requestInfo.rw) {
16
- throw new Error(`
17
- rwsdk: A database created using createDb() was accessed before requestInfo was available.
18
-
19
- Please make sure database access is happening in a request handler or action handler.
20
- `);
14
+ const cacheKey = `${durableObjectBinding.toString()}_${name}`;
15
+ const getDb = () => {
16
+ // requestInfo is available
17
+ if (requestInfo.rw) {
18
+ if (!requestInfo.rw.databases) {
19
+ requestInfo.rw.databases = new Map();
20
+ }
21
+ let db = requestInfo.rw.databases.get(cacheKey);
22
+ // db is in requestInfo cache
23
+ if (db) {
24
+ return db;
25
+ }
26
+ // db is in module-level cache
27
+ const moduleDb = moduleLevelDbCache.get(cacheKey);
28
+ if (moduleDb) {
29
+ requestInfo.rw.databases.set(cacheKey, moduleDb);
30
+ moduleLevelDbCache.delete(cacheKey);
31
+ return moduleDb;
32
+ }
33
+ // db is not in any cache
34
+ db = createDurableObjectDb(durableObjectBinding, name);
35
+ requestInfo.rw.databases.set(cacheKey, db);
36
+ return db;
21
37
  }
22
- let db = requestInfo.rw.databases.get(cacheKey);
38
+ // requestInfo is not available, use module-level cache
39
+ let db = moduleLevelDbCache.get(cacheKey);
23
40
  if (!db) {
24
41
  db = createDurableObjectDb(durableObjectBinding, name);
25
- requestInfo.rw.databases.set(cacheKey, db);
42
+ moduleLevelDbCache.set(cacheKey, db);
26
43
  }
27
44
  return db;
28
45
  };
29
- waitForRequestInfo().then(() => doCreateDb());
30
46
  return new Proxy({}, {
31
- get(target, prop, receiver) {
32
- const db = doCreateDb();
47
+ get(target, prop) {
48
+ const db = getDb();
33
49
  const value = db[prop];
34
50
  if (typeof value === "function") {
35
51
  return value.bind(db);
@@ -4,10 +4,7 @@ export const getManifest = async (requestInfo) => {
4
4
  return manifest;
5
5
  }
6
6
  if (import.meta.env.VITE_IS_DEV_SERVER) {
7
- const url = new URL(requestInfo.request.url);
8
- url.searchParams.set("scripts", JSON.stringify(Array.from(requestInfo.rw.scriptsToBeLoaded)));
9
- url.pathname = "/__rwsdk_manifest";
10
- manifest = await fetch(url.toString()).then((res) => res.json());
7
+ manifest = {};
11
8
  }
12
9
  else {
13
10
  const { default: prodManifest } = await import("virtual:rwsdk:manifest.js");
@@ -1,9 +1,4 @@
1
1
  import { type RequestInfo } from "../requestInfo/types.js";
2
- export type CssEntry = {
3
- url: string;
4
- content: string;
5
- absolutePath: string;
6
- };
7
2
  export declare const Stylesheets: ({ requestInfo }: {
8
3
  requestInfo: RequestInfo;
9
4
  }) => import("react/jsx-runtime.js").JSX.Element;
@@ -31,15 +31,5 @@ export const Stylesheets = ({ requestInfo }) => {
31
31
  allStylesheets.add(entry);
32
32
  }
33
33
  }
34
- return (_jsx(_Fragment, { children: Array.from(allStylesheets).map((entry) => {
35
- if (typeof entry === "string") {
36
- return (_jsx("link", { rel: "stylesheet", href: entry, precedence: "first" }, entry));
37
- }
38
- if (import.meta.env.VITE_IS_DEV_SERVER) {
39
- return (_jsx("style", { "data-vite-dev-id": entry.absolutePath, dangerouslySetInnerHTML: { __html: entry.content } }, entry.url));
40
- }
41
- else {
42
- return (_jsx("link", { rel: "stylesheet", href: entry.url, precedence: "first" }, entry.url));
43
- }
44
- }) }));
34
+ return (_jsx(_Fragment, { children: Array.from(allStylesheets).map((href) => (_jsx("link", { rel: "stylesheet", href: href, precedence: "first" }, href))) }));
45
35
  };
@@ -24,108 +24,12 @@ const getPackageManagerInfo = (targetDir) => {
24
24
  }
25
25
  return pnpmResult;
26
26
  };
27
- /**
28
- * @summary Workaround for pnpm's local tarball dependency resolution.
29
- *
30
- * @description
31
- * When installing a new version of the SDK from a local tarball (e.g., during
32
- * development with `rwsync`), pnpm creates a new, uniquely-named directory in
33
- * the `.pnpm` store (e.g., `rwsdk@file+...`).
34
- *
35
- * A challenge arises when other packages list `rwsdk` as a peer dependency.
36
- * pnpm may not consistently update the symlinks for these peer dependencies
37
- * to point to the newest `rwsdk` instance. This can result in a state where
38
- * multiple versions of `rwsdk` coexist in `node_modules`, with some parts of
39
- * the application using a stale version.
40
- *
41
- * This function addresses the issue by:
42
- * 1. Identifying the most recently installed `rwsdk` instance in the `.pnpm`
43
- * store after a `pnpm install` run.
44
- * 2. Forcefully updating the top-level `node_modules/rwsdk` symlink to point
45
- * to this new instance.
46
- * 3. Traversing all other `rwsdk`-related directories in the `.pnpm` store
47
- * and updating their internal `rwsdk` symlinks to also point to the correct
48
- * new instance.
49
- *
50
- * I am sorry for this ugly hack, I am sure there is a better way, and that it is me
51
- * doing something wrong. The aim is not to go down this rabbit hole right now
52
- * -- @justinvdm
53
- */
54
- const hackyPnpmSymlinkFix = async (targetDir) => {
55
- console.log("💣 Performing pnpm symlink fix...");
56
- const pnpmDir = path.join(targetDir, "node_modules", ".pnpm");
57
- if (!existsSync(pnpmDir)) {
58
- console.log(" 🤔 No .pnpm directory found.");
59
- return;
60
- }
61
- try {
62
- const entries = await fs.readdir(pnpmDir);
63
- // Find ALL rwsdk directories, not just file-based ones, to handle
64
- // all kinds of stale peer dependencies.
65
- const rwsdkDirs = entries.filter((e) => e.startsWith("rwsdk@"));
66
- console.log(" Found rwsdk directories:", rwsdkDirs);
67
- if (rwsdkDirs.length === 0) {
68
- console.log(" 🤔 No rwsdk directories found to hack.");
69
- return;
70
- }
71
- let latestDir = "";
72
- let latestMtime = new Date(0);
73
- for (const dir of rwsdkDirs) {
74
- const fullPath = path.join(pnpmDir, dir);
75
- const stats = await fs.stat(fullPath);
76
- if (stats.mtime > latestMtime) {
77
- latestMtime = stats.mtime;
78
- latestDir = dir;
79
- }
80
- }
81
- console.log(" Latest rwsdk directory:", latestDir);
82
- if (!latestDir) {
83
- console.log(" 🤔 Could not determine the latest rwsdk directory.");
84
- return;
85
- }
86
- const goldenSourcePath = path.join(pnpmDir, latestDir, "node_modules", "rwsdk");
87
- if (!existsSync(goldenSourcePath)) {
88
- console.error(` ❌ Golden source path does not exist: ${goldenSourcePath}`);
89
- return;
90
- }
91
- console.log(` 🎯 Golden rwsdk path is: ${goldenSourcePath}`);
92
- // 1. Fix top-level symlink
93
- const topLevelSymlink = path.join(targetDir, "node_modules", "rwsdk");
94
- await fs.rm(topLevelSymlink, { recursive: true, force: true });
95
- await fs.symlink(goldenSourcePath, topLevelSymlink, "dir");
96
- console.log(` ✅ Symlinked ${topLevelSymlink} -> ${goldenSourcePath}`);
97
- // 2. Fix peer dependency symlinks
98
- const allPnpmDirs = await fs.readdir(pnpmDir);
99
- for (const dir of allPnpmDirs) {
100
- if (dir === latestDir || !dir.includes("rwsdk"))
101
- continue;
102
- const peerSymlink = path.join(pnpmDir, dir, "node_modules", "rwsdk");
103
- if (existsSync(peerSymlink)) {
104
- await fs.rm(peerSymlink, { recursive: true, force: true });
105
- await fs.symlink(goldenSourcePath, peerSymlink, "dir");
106
- console.log(` ✅ Hijacked symlink in ${dir}`);
107
- }
108
- }
109
- }
110
- catch (error) {
111
- console.error(" ❌ Failed during hacky pnpm symlink fix:", error);
112
- }
113
- };
114
- const performFullSync = async (sdkDir, targetDir, cacheBust = false) => {
27
+ const performFullSync = async (sdkDir, targetDir) => {
115
28
  const sdkPackageJsonPath = path.join(sdkDir, "package.json");
116
29
  let originalSdkPackageJson = null;
117
30
  let tarballPath = "";
118
31
  let tarballName = "";
119
32
  try {
120
- if (cacheBust) {
121
- console.log("💥 Cache-busting version for full sync...");
122
- originalSdkPackageJson = await fs.readFile(sdkPackageJsonPath, "utf-8");
123
- const packageJson = JSON.parse(originalSdkPackageJson);
124
- const now = Date.now();
125
- // This is a temporary version used for cache busting
126
- packageJson.version = `${packageJson.version}-dev.${now}`;
127
- await fs.writeFile(sdkPackageJsonPath, JSON.stringify(packageJson, null, 2));
128
- }
129
33
  console.log("📦 Packing SDK...");
130
34
  const packResult = await $({ cwd: sdkDir }) `npm pack`;
131
35
  tarballName = packResult.stdout?.trim() ?? "";
@@ -145,47 +49,25 @@ const performFullSync = async (sdkDir, targetDir, cacheBust = false) => {
145
49
  .readFile(lockfilePath, "utf-8")
146
50
  .catch(() => null);
147
51
  try {
148
- if (pm.name === "pnpm") {
149
- console.log("🛠️ Using pnpm overrides to install SDK...");
150
- if (originalPackageJson) {
151
- const targetPackageJson = JSON.parse(originalPackageJson);
152
- targetPackageJson.pnpm = targetPackageJson.pnpm || {};
153
- targetPackageJson.pnpm.overrides =
154
- targetPackageJson.pnpm.overrides || {};
155
- targetPackageJson.pnpm.overrides.rwsdk = `file:${tarballPath}`;
156
- await fs.writeFile(packageJsonPath, JSON.stringify(targetPackageJson, null, 2));
157
- }
158
- // We use install here, which respects the overrides.
159
- // We also don't want to fail if the lockfile is out of date.
160
- await $("pnpm", ["install", "--no-frozen-lockfile"], {
161
- cwd: targetDir,
162
- stdio: "inherit",
163
- });
164
- if (process.env.RWSDK_PNPM_SYMLINK_FIX) {
165
- await hackyPnpmSymlinkFix(targetDir);
166
- }
52
+ const cmd = pm.name;
53
+ const args = [pm.command];
54
+ if (pm.name === "yarn") {
55
+ args.push(`file:${tarballPath}`);
167
56
  }
168
57
  else {
169
- const cmd = pm.name;
170
- const args = [pm.command];
171
- if (pm.name === "yarn") {
172
- args.push(`file:${tarballPath}`);
173
- }
174
- else {
175
- args.push(tarballPath);
176
- }
177
- await $(cmd, args, {
178
- cwd: targetDir,
179
- stdio: "inherit",
180
- });
58
+ args.push(tarballPath);
181
59
  }
60
+ await $(cmd, args, {
61
+ cwd: targetDir,
62
+ stdio: "inherit",
63
+ });
182
64
  }
183
65
  finally {
184
66
  if (originalPackageJson) {
185
67
  console.log("Restoring package.json...");
186
68
  await fs.writeFile(packageJsonPath, originalPackageJson);
187
69
  }
188
- if (originalLockfile && pm.name !== "pnpm") {
70
+ if (originalLockfile) {
189
71
  console.log(`Restoring ${pm.lockFile}...`);
190
72
  await fs.writeFile(lockfilePath, originalLockfile);
191
73
  }
@@ -218,13 +100,17 @@ const performFastSync = async (sdkDir, targetDir) => {
218
100
  // Always copy package.json
219
101
  await fs.copyFile(path.join(sdkDir, "package.json"), path.join(targetDir, "node_modules/rwsdk/package.json"));
220
102
  };
103
+ const areDependenciesEqual = (deps1, deps2) => {
104
+ // Simple string comparison for this use case is sufficient
105
+ return JSON.stringify(deps1 ?? {}) === JSON.stringify(deps2 ?? {});
106
+ };
221
107
  const performSync = async (sdkDir, targetDir) => {
222
108
  console.log("🏗️ Rebuilding SDK...");
223
109
  await $ `pnpm build`;
224
110
  const forceFullSync = Boolean(process.env.RWSDK_FORCE_FULL_SYNC);
225
111
  if (forceFullSync) {
226
112
  console.log("🏃 Force full sync mode is enabled.");
227
- await performFullSync(sdkDir, targetDir, true);
113
+ await performFullSync(sdkDir, targetDir);
228
114
  console.log("✅ Done syncing");
229
115
  return;
230
116
  }
@@ -234,15 +120,17 @@ const performSync = async (sdkDir, targetDir) => {
234
120
  if (existsSync(installedSdkPackageJsonPath)) {
235
121
  const sdkPackageJsonContent = await fs.readFile(sdkPackageJsonPath, "utf-8");
236
122
  const installedSdkPackageJsonContent = await fs.readFile(installedSdkPackageJsonPath, "utf-8");
237
- if (sdkPackageJsonContent === installedSdkPackageJsonContent) {
123
+ const sdkPkg = JSON.parse(sdkPackageJsonContent);
124
+ const installedPkg = JSON.parse(installedSdkPackageJsonContent);
125
+ if (areDependenciesEqual(sdkPkg.dependencies, installedPkg.dependencies) &&
126
+ areDependenciesEqual(sdkPkg.devDependencies, installedPkg.devDependencies) &&
127
+ areDependenciesEqual(sdkPkg.peerDependencies, installedPkg.peerDependencies)) {
238
128
  packageJsonChanged = false;
239
129
  }
240
130
  }
241
131
  if (packageJsonChanged) {
242
132
  console.log("📦 package.json changed, performing full sync...");
243
- // We always cache-bust on a full sync now to ensure pnpm's overrides
244
- // see a new version and the hacky symlink fix runs on a clean slate.
245
- await performFullSync(sdkDir, targetDir, true);
133
+ await performFullSync(sdkDir, targetDir);
246
134
  }
247
135
  else {
248
136
  await performFastSync(sdkDir, targetDir);
@@ -261,8 +149,7 @@ export const debugSync = async (opts) => {
261
149
  return;
262
150
  }
263
151
  // --- Watch Mode Logic ---
264
- // Use global lock based on SDK directory since all instances sync from the same source
265
- const lockfilePath = path.join(sdkDir, ".rwsync.lock");
152
+ const lockfilePath = path.join(targetDir, "node_modules", ".rwsync.lock");
266
153
  let release;
267
154
  // Ensure the directory for the lockfile exists
268
155
  await fs.mkdir(path.dirname(lockfilePath), { recursive: true });
@@ -273,7 +160,7 @@ export const debugSync = async (opts) => {
273
160
  }
274
161
  catch (e) {
275
162
  if (e.code === "ELOCKED") {
276
- console.error(`❌ Another rwsync process is already running for this SDK.`);
163
+ console.error(`❌ Another rwsync process is already watching ${targetDir}.`);
277
164
  console.error(` If this is not correct, please remove the lockfile at ${lockfilePath}`);
278
165
  process.exit(1);
279
166
  }
@@ -30,8 +30,7 @@ if (fileURLToPath(import.meta.url) === process.argv[1]) {
30
30
  copyProject: false, // Default to false - don't copy project to artifacts
31
31
  realtime: false, // Default to false - don't just test realtime
32
32
  skipHmr: false, // Default to false - run HMR tests
33
- // todo(justinvdm, 2025-07-31): Remove this once style tests working with headless
34
- skipStyleTests: true, // Default to true - skip style tests
33
+ skipStyleTests: false,
35
34
  // sync: will be set below
36
35
  };
37
36
  // Log if we're in CI
@@ -55,8 +54,8 @@ if (fileURLToPath(import.meta.url) === process.argv[1]) {
55
54
  else if (arg === "--skip-hmr") {
56
55
  options.skipHmr = true;
57
56
  }
58
- else if (arg === "--run-style-tests") {
59
- options.skipStyleTests = false;
57
+ else if (arg === "--skip-style-tests") {
58
+ options.skipStyleTests = true;
60
59
  }
61
60
  else if (arg === "--keep") {
62
61
  options.keep = true;
@@ -94,7 +93,7 @@ Options:
94
93
  --skip-release Skip testing the release/production deployment
95
94
  --skip-client Skip client-side tests, only run server-side checks
96
95
  --skip-hmr Skip hot module replacement (HMR) tests
97
- --run-style-tests Enable stylesheet-related tests (disabled by default)
96
+ --skip-style-tests Skip stylesheet-related tests
98
97
  --path=PATH Project directory to test
99
98
  --artifact-dir=DIR Directory to store test artifacts (default: .artifacts)
100
99
  --keep Keep temporary test directory after tests complete
@@ -4,36 +4,6 @@ import { normalizeModulePath } from "../lib/normalizeModulePath.mjs";
4
4
  const log = debug("rwsdk:vite:manifest-plugin");
5
5
  const virtualModuleId = "virtual:rwsdk:manifest.js";
6
6
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
7
- const getCssForModule = (server, moduleId, css) => {
8
- const stack = [moduleId];
9
- const visited = new Set();
10
- while (stack.length > 0) {
11
- const currentModuleId = stack.pop();
12
- if (visited.has(currentModuleId)) {
13
- continue;
14
- }
15
- visited.add(currentModuleId);
16
- const moduleNode = server.environments.client.moduleGraph.getModuleById(currentModuleId);
17
- if (!moduleNode) {
18
- continue;
19
- }
20
- for (const importedModule of moduleNode.importedModules) {
21
- if (importedModule.url.endsWith(".css")) {
22
- const absolutePath = importedModule.file;
23
- css.add({
24
- url: importedModule.url,
25
- // The `ssrTransformResult` has the CSS content, because the default
26
- // transform for CSS is to a string of the CSS content.
27
- content: importedModule.ssrTransformResult?.code ?? "",
28
- absolutePath,
29
- });
30
- }
31
- if (importedModule.id) {
32
- stack.push(importedModule.id);
33
- }
34
- }
35
- }
36
- };
37
7
  export const manifestPlugin = ({ manifestPath, }) => {
38
8
  let isBuild = false;
39
9
  let root;
@@ -106,46 +76,5 @@ export const manifestPlugin = ({ manifestPath, }) => {
106
76
  },
107
77
  });
108
78
  },
109
- configureServer(server) {
110
- log("Configuring server middleware for manifest");
111
- server.middlewares.use("/__rwsdk_manifest", async (req, res, next) => {
112
- log("Manifest request received: %s", req.url);
113
- try {
114
- const url = new URL(req.url, `http://${req.headers.host}`);
115
- const scripts = JSON.parse(url.searchParams.get("scripts") || "[]");
116
- process.env.VERBOSE && log("Transforming scripts: %o", scripts);
117
- for (const script of scripts) {
118
- await server.environments.client.transformRequest(script);
119
- }
120
- const manifest = {};
121
- log("Building manifest from module graph");
122
- for (const file of server.environments.client.moduleGraph.fileToModulesMap.keys()) {
123
- const modules = server.environments.client.moduleGraph.getModulesByFile(file);
124
- if (!modules) {
125
- continue;
126
- }
127
- for (const module of modules) {
128
- if (module.file) {
129
- const css = new Set();
130
- getCssForModule(server, module.id, css);
131
- manifest[normalizeModulePath(module.file, server.config.root)] =
132
- {
133
- file: module.url,
134
- css: Array.from(css),
135
- };
136
- }
137
- }
138
- }
139
- log("Manifest built successfully");
140
- process.env.VERBOSE && log("Manifest: %o", manifest);
141
- res.setHeader("Content-Type", "application/json");
142
- res.end(JSON.stringify(manifest));
143
- }
144
- catch (e) {
145
- log("Error building manifest: %o", e);
146
- next(e);
147
- }
148
- });
149
- },
150
79
  };
151
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "0.2.0-alpha.5",
3
+ "version": "0.2.0-alpha.6-test.20250806100800",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {