rwsdk 1.0.0-beta.37 → 1.0.0-beta.38

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.
@@ -56,6 +56,7 @@ export const configPlugin = ({ silent, projectRootDir, workerEntryPathname, clie
56
56
  build: {
57
57
  outDir: resolve(projectRootDir, "dist", "worker"),
58
58
  emitAssets: true,
59
+ ssrManifest: true,
59
60
  emptyOutDir: false,
60
61
  ssr: true,
61
62
  },
@@ -0,0 +1,4 @@
1
+ import { Plugin } from "vite";
2
+ export declare const diagnosticAssetGraphPlugin: ({ rootDir, }: {
3
+ rootDir: string;
4
+ }) => Plugin;
@@ -0,0 +1,41 @@
1
+ export const diagnosticAssetGraphPlugin = ({ rootDir, }) => ({
2
+ name: "rwsdk:diagnostic-asset-graph",
3
+ apply: "build",
4
+ async buildEnd() {
5
+ if (this.environment.name === "worker" &&
6
+ process.env.RWSDK_BUILD_PASS === "worker") {
7
+ console.log("\n=== Asset Graph Diagnostic ===");
8
+ const moduleIds = Array.from(this.getModuleIds());
9
+ console.log(`Total modules: ${moduleIds.length}`);
10
+ const urlImportedModules = new Set();
11
+ const publicAssets = new Set();
12
+ for (const moduleId of moduleIds) {
13
+ const moduleInfo = this.getModuleInfo(moduleId);
14
+ if (moduleInfo) {
15
+ const isImportedByUrl = moduleInfo.importers.some((importer) => importer.includes("?url")) || moduleId.includes("?url");
16
+ if (isImportedByUrl) {
17
+ urlImportedModules.add(moduleId);
18
+ console.log(`\nModule imported with ?url: ${moduleId}`);
19
+ console.log(` Importers: ${moduleInfo.importers.join(", ")}`);
20
+ if (moduleInfo.importedIds) {
21
+ console.log(` Imports: ${moduleInfo.importedIds.join(", ")}`);
22
+ for (const importedId of moduleInfo.importedIds) {
23
+ publicAssets.add(importedId);
24
+ }
25
+ }
26
+ }
27
+ if (moduleInfo.importers.some((importer) => importer.includes("Document.tsx"))) {
28
+ console.log(`\nModule imported by Document.tsx: ${moduleId}`);
29
+ console.log(` Importers: ${moduleInfo.importers.join(", ")}`);
30
+ if (moduleInfo.importedIds) {
31
+ console.log(` Imports: ${moduleInfo.importedIds.join(", ")}`);
32
+ }
33
+ }
34
+ }
35
+ }
36
+ console.log(`\nTotal modules imported with ?url: ${urlImportedModules.size}`);
37
+ console.log(`Total transitive dependencies: ${publicAssets.size}`);
38
+ console.log("\n=== End Asset Graph Diagnostic ===\n");
39
+ }
40
+ },
41
+ });
@@ -11,8 +11,25 @@ export const moveStaticAssetsPlugin = ({ rootDir, }) => ({
11
11
  if (!(await fs.pathExists(sourceDir))) {
12
12
  return;
13
13
  }
14
+ const ssrManifestPath = path.join(rootDir, "dist", "worker", ".vite", "ssr-manifest.json");
15
+ if (!(await fs.pathExists(ssrManifestPath))) {
16
+ return;
17
+ }
18
+ const manifestContent = await fs.readFile(ssrManifestPath, "utf-8");
19
+ const ssrManifest = JSON.parse(manifestContent);
20
+ const publicAssets = new Set();
21
+ for (const [moduleId, assetPaths] of Object.entries(ssrManifest)) {
22
+ if (moduleId.includes("?url")) {
23
+ for (const assetPath of assetPaths) {
24
+ const assetFileName = path.basename(assetPath);
25
+ publicAssets.add(assetFileName);
26
+ }
27
+ }
28
+ }
14
29
  const allFiles = await fs.readdir(sourceDir);
15
- const filesToMove = allFiles.filter((file) => !file.endsWith(".js") && !file.endsWith(".map"));
30
+ const filesToMove = allFiles.filter((file) => !file.endsWith(".js") &&
31
+ !file.endsWith(".map") &&
32
+ publicAssets.has(file));
16
33
  if (filesToMove.length > 0) {
17
34
  await fs.ensureDir(destDir);
18
35
  for (const file of filesToMove) {
@@ -21,6 +38,7 @@ export const moveStaticAssetsPlugin = ({ rootDir, }) => ({
21
38
  await fs.move(sourceFile, destFile, { overwrite: true });
22
39
  }
23
40
  }
41
+ await fs.remove(ssrManifestPath);
24
42
  }
25
43
  },
26
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "1.0.0-beta.37",
3
+ "version": "1.0.0-beta.38",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {