alchemy 0.12.1 → 0.12.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.
@@ -9,6 +9,7 @@ export * from "./d1-database";
9
9
  export * from "./dns-records";
10
10
  export * from "./durable-object-namespace";
11
11
  export * from "./kv-namespace";
12
+ export * from "./local-dev-cloudflare-shim";
12
13
  export * from "./permission-groups";
13
14
  export * from "./pipeline";
14
15
  export * from "./queue";
@@ -9,6 +9,7 @@ export * from "./d1-database";
9
9
  export * from "./dns-records";
10
10
  export * from "./durable-object-namespace";
11
11
  export * from "./kv-namespace";
12
+ export * from "./local-dev-cloudflare-shim";
12
13
  export * from "./permission-groups";
13
14
  export * from "./pipeline";
14
15
  export * from "./queue";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * TanStackStart server functions and middleware run in Node.js intead of Miniflare when using `vite dev`.
3
+ *
4
+ * This plugin polyfills the cloudflare:workers module during the dev server phase.
5
+ */
6
+ export declare function cloudflareWorkersDevEnvironmentShim(): {
7
+ readonly name: "cloudflare-workers-dev-shim";
8
+ readonly apply: "serve";
9
+ readonly enforce: "pre";
10
+ readonly resolveId: (id: string) => "cloudflare:workers" | undefined;
11
+ readonly load: (id: string) => "\nimport { getPlatformProxy } from \"wrangler\";\n// TODO: should we export default cloudflare; ??\nconst cloudflare = await getPlatformProxy();\nexport const env = cloudflare.env;\n" | undefined;
12
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * TanStackStart server functions and middleware run in Node.js intead of Miniflare when using `vite dev`.
3
+ *
4
+ * This plugin polyfills the cloudflare:workers module during the dev server phase.
5
+ */
6
+ export function cloudflareWorkersDevEnvironmentShim() {
7
+ return {
8
+ name: "cloudflare-workers-dev-shim",
9
+ apply: "serve", // dev‑only
10
+ enforce: "pre",
11
+ resolveId(id) {
12
+ if (id === "cloudflare:workers")
13
+ return id; // tell Vite we handled it
14
+ },
15
+ load(id) {
16
+ if (id === "cloudflare:workers")
17
+ return `
18
+ import { getPlatformProxy } from "wrangler";
19
+ // TODO: should we export default cloudflare; ??
20
+ const cloudflare = await getPlatformProxy();
21
+ export const env = cloudflare.env;
22
+ `;
23
+ },
24
+ };
25
+ }
@@ -3,7 +3,7 @@ export async function TanStackStart(id, props) {
3
3
  return Website(id, {
4
4
  ...props,
5
5
  command: props?.command ?? "bun run build",
6
- wrangler: props?.wrangler ?? false,
6
+ wrangler: props?.wrangler ?? true,
7
7
  main: props?.main ?? ".output/server/index.mjs",
8
8
  compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
9
9
  assets: props?.assets ?? ".output/public",
@@ -28,7 +28,7 @@ export const WranglerJson = Resource("cloudflare::WranglerJson", async function
28
28
  if (worker.env) {
29
29
  spec.vars = { ...worker.env };
30
30
  }
31
- await StaticJsonFile("wrangler.json", spec);
31
+ await StaticJsonFile(filePath, spec);
32
32
  // Return the resource
33
33
  return this({
34
34
  ...props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "type": "module",
5
5
  "module": "./lib/index.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@ export * from "./d1-database";
9
9
  export * from "./dns-records";
10
10
  export * from "./durable-object-namespace";
11
11
  export * from "./kv-namespace";
12
+ export * from "./local-dev-cloudflare-shim";
12
13
  export * from "./permission-groups";
13
14
  export * from "./pipeline";
14
15
  export * from "./queue";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * TanStackStart server functions and middleware run in Node.js intead of Miniflare when using `vite dev`.
3
+ *
4
+ * This plugin polyfills the cloudflare:workers module during the dev server phase.
5
+ */
6
+ export function cloudflareWorkersDevEnvironmentShim() {
7
+ return {
8
+ name: "cloudflare-workers-dev-shim",
9
+ apply: "serve", // dev‑only
10
+ enforce: "pre",
11
+ resolveId(id: string) {
12
+ if (id === "cloudflare:workers") return id; // tell Vite we handled it
13
+ },
14
+ load(id: string) {
15
+ if (id === "cloudflare:workers")
16
+ return `
17
+ import { getPlatformProxy } from "wrangler";
18
+ // TODO: should we export default cloudflare; ??
19
+ const cloudflare = await getPlatformProxy();
20
+ export const env = cloudflare.env;
21
+ `;
22
+ },
23
+ } as const;
24
+ }
@@ -18,7 +18,7 @@ export async function TanStackStart<B extends Bindings>(
18
18
  return Website(id, {
19
19
  ...props,
20
20
  command: props?.command ?? "bun run build",
21
- wrangler: props?.wrangler ?? false,
21
+ wrangler: props?.wrangler ?? true,
22
22
  main: props?.main ?? ".output/server/index.mjs",
23
23
  compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
24
24
  assets: props?.assets ?? ".output/public",
@@ -87,7 +87,7 @@ export const WranglerJson = Resource(
87
87
  spec.vars = { ...worker.env };
88
88
  }
89
89
 
90
- await StaticJsonFile("wrangler.json", spec);
90
+ await StaticJsonFile(filePath, spec);
91
91
 
92
92
  // Return the resource
93
93
  return this({
@@ -207,7 +207,7 @@ export interface WranglerJsonSpec {
207
207
  binding: string;
208
208
  database_id: string;
209
209
  database_name: string;
210
- migrations_dir?: string
210
+ migrations_dir?: string;
211
211
  }[];
212
212
 
213
213
  /**
package/src/env.ts CHANGED
@@ -23,7 +23,7 @@ async function _env<T = string>(
23
23
  try {
24
24
  const { env } = await import("cloudflare:workers");
25
25
  if (name in env) {
26
- return env[name as keyof typeof env];
26
+ return env[name as keyof typeof env] as T;
27
27
  }
28
28
  } catch (error) {}
29
29
  }