rwsdk 0.1.1 → 0.1.2

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.
@@ -1,4 +1,5 @@
1
1
  import { resolve } from "node:path";
2
+ import { unstable_readConfig } from "wrangler";
2
3
  import { cloudflare } from "@cloudflare/vite-plugin";
3
4
  import { hasOwnCloudflareVitePlugin } from "./hasOwnCloudflareVitePlugin.mjs";
4
5
  import reactPlugin from "@vitejs/plugin-react";
@@ -20,14 +21,22 @@ import { prismaPlugin } from "./prismaPlugin.mjs";
20
21
  import { ssrBridgePlugin } from "./ssrBridgePlugin.mjs";
21
22
  import { hasPkgScript } from "../lib/hasPkgScript.mjs";
22
23
  import { devServerTimingPlugin } from "./devServerTimingPlugin.mjs";
24
+ const determineWorkerEntryPathname = async (projectRootDir, workerConfigPath, options) => {
25
+ if (options.entry?.worker) {
26
+ return resolve(projectRootDir, options.entry.worker);
27
+ }
28
+ const workerConfig = unstable_readConfig({ config: workerConfigPath });
29
+ return resolve(projectRootDir, workerConfig.main ?? "src/worker.tsx");
30
+ };
23
31
  export const redwoodPlugin = async (options = {}) => {
24
32
  const projectRootDir = process.cwd();
25
33
  const mode = options.mode ??
26
34
  (process.env.NODE_ENV === "development" ? "development" : "production");
35
+ const workerConfigPath = options.configPath ?? (await findWranglerConfig(projectRootDir));
36
+ const workerEntryPathname = await determineWorkerEntryPathname(projectRootDir, workerConfigPath, options);
27
37
  const clientEntryPathnames = (Array.isArray(options.entry?.client)
28
38
  ? options.entry.client
29
39
  : [options.entry?.client ?? "src/client.tsx"]).map((entry) => resolve(projectRootDir, entry));
30
- const workerEntryPathname = resolve(projectRootDir, options?.entry?.worker ?? "src/worker.tsx");
31
40
  const clientFiles = new Set();
32
41
  const serverFiles = new Set();
33
42
  const shouldIncludeCloudflarePlugin = options.includeCloudflarePlugin ??
@@ -64,7 +73,7 @@ export const redwoodPlugin = async (options = {}) => {
64
73
  shouldIncludeCloudflarePlugin
65
74
  ? cloudflare({
66
75
  viteEnvironment: { name: "worker" },
67
- configPath: options.configPath ?? (await findWranglerConfig(projectRootDir)),
76
+ configPath: workerConfigPath,
68
77
  })
69
78
  : [],
70
79
  miniflareHMRPlugin({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {