Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alchemy/bin/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const dependencyVersionMap = {
wrangler: "^4.20.5",

// astro
"@astrojs/cloudflare": "^12.6.0",
"@astrojs/cloudflare": "^13.0.1",

// nuxt
"nitro-cloudflare-dev": "^0.2.2",
Expand Down
8 changes: 4 additions & 4 deletions alchemy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
"yaml": "^2.0.0"
},
"peerDependencies": {
"@astrojs/cloudflare": "^12.6.4",
"@astrojs/cloudflare": "^13.0.0",
"@aws-sdk/client-dynamodb": "^3.0.0",
"@aws-sdk/client-iam": "^3.0.0",
"@aws-sdk/client-lambda": "^3.0.0",
Expand All @@ -221,7 +221,7 @@
"@coinbase/cdp-sdk": "^0.10.0",
"@libsql/client": "^0.15.12",
"@opennextjs/cloudflare": "^1.6.5",
"astro": "^5.13.2",
"astro": "^6.0.0",
"rwsdk": "^1.0.0-beta.51",
"stripe": "^18.5.0",
"vite": ">=6.0.0",
Expand Down Expand Up @@ -281,7 +281,7 @@
}
},
"devDependencies": {
"@astrojs/cloudflare": "^12.6.4",
"@astrojs/cloudflare": "^13.0.1",
"@aws-sdk/client-dynamodb": "^3.0.0",
"@aws-sdk/client-ec2": "^3.868.0",
"@aws-sdk/client-iam": "^3.864.0",
Expand Down Expand Up @@ -309,7 +309,7 @@
"@types/ws": "^8.18.1",
"@workos-inc/node": "^7.69.1",
"arktype": "^2.1.16",
"astro": "^5.13.2",
"astro": "^6.0.1",
"braintrust": "^0.0.201",
"capnweb": "^0.4.0",
"cojson-core-wasm": "^0.18.16",
Expand Down
12 changes: 10 additions & 2 deletions alchemy/src/cloudflare/astro/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,16 @@ export async function Astro<B extends Bindings>(
dev: spreadDevProps(props, `${runner} astro dev`),
entrypoint:
props.entrypoint ??
(output === "server" ? "dist/_worker.js/index.js" : undefined),
assets: props.assets ?? "dist",
(output === "server" ? "dist/server/entry.mjs" : undefined),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still work for older astro?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this would break Astro 5.

Astro 5 still outputs:

dist/_worker.js/index.js

I’m not sure we can reliably infer v5 vs v6 inside the resource

I thinkmaybe we just update the docs?

keep these defaults aligned to Astro 6
document the Astro 5 override explicitly

Something like:

await Astro("website", {
  entrypoint: "dist/_worker.js/index.js",
  assets: "dist",
  wrangler: {
    main: "@astrojs/cloudflare/entrypoints/server.js",
  },
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a version prop? we default to astroVersion: 5 so we don't break it for existing users and anyone who wants to use astro 6 would explicitly say astroVersion: 6.

or we just version the entire resource but that feels like overkill. We should really avoid breaking userspace

assets: props.assets ?? (output === "server" ? "dist/client" : "dist"),
wrangler: {
...props.wrangler,
main:
props.wrangler?.main ??
(output === "server"
? "@astrojs/cloudflare/entrypoints/server"
: undefined),
},
spa: false,
});
}
Expand Down
32 changes: 25 additions & 7 deletions alchemy/src/cloudflare/astro/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
import path from "pathe";
import cloudflare, { type Options } from "@astrojs/cloudflare";
import type { AstroIntegration } from "astro";
import type { GetPlatformProxyOptions } from "wrangler";
import { getPlatformProxyOptions } from "../cloudflare-env-proxy.ts";

const isAstroCheck =
!!process.argv.find((arg) => arg.includes("astro")) &&
process.argv.includes("check");

const alchemy = (options?: Options): AstroIntegration => {
type AlchemyAstroOptions = Options & {
platformProxy?: GetPlatformProxyOptions & {
enabled?: boolean;
};
};

const alchemy = (options?: AlchemyAstroOptions): AstroIntegration => {
const { platformProxy: proxyOptions, ...config } = options ?? {};
const platformProxy = getPlatformProxyOptions(proxyOptions, !isAstroCheck);
let persistState =
config.persistState ??
(platformProxy.persist === false
? false
: {
path: platformProxy.persist.path,
});
if (typeof persistState === "object" && persistState.path.endsWith("v3")) {
persistState.path = path.dirname(persistState.path);
}
const integration = cloudflare({
platformProxy: getPlatformProxyOptions(
options?.platformProxy,
!isAstroCheck,
),
...options,
});
...config,
configPath: config.configPath ?? platformProxy.configPath,
persistState,
} satisfies Options);
const setup = integration.hooks["astro:config:setup"];
integration.hooks["astro:config:setup"] = async (options) => {
options.updateConfig({
Expand Down
10 changes: 9 additions & 1 deletion alchemy/src/cloudflare/cloudflare-env-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import {
validateConfigPath,
} from "./miniflare/paths.ts";

export type PlatformProxyOptions = Omit<
GetPlatformProxyOptions,
"configPath" | "persist"
> & {
configPath: string;
persist: false | { path: string };
};

export const getCloudflareEnvProxy = async <E>(
options: GetPlatformProxyOptions = {},
) => {
Expand All @@ -17,7 +25,7 @@ export const getCloudflareEnvProxy = async <E>(
export const getPlatformProxyOptions = (
input: GetPlatformProxyOptions = {},
throws: boolean = true,
): GetPlatformProxyOptions => {
): PlatformProxyOptions => {
const persist =
input.persist === false
? false
Expand Down
4 changes: 2 additions & 2 deletions alchemy/templates/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"preview": "astro preview"
},
"dependencies": {
"astro": "^5.10.0"
"astro": "^6.0.1"
},
"devDependencies": {
"alchemy": "workspace:*",
"@astrojs/cloudflare": "^12.6.0",
"@astrojs/cloudflare": "^13.0.1",
"miniflare": "^4.20250617.3",
"@cloudflare/workers-types": "^4.20250805.0",
"typescript": "^5.8.3"
Expand Down
4 changes: 2 additions & 2 deletions alchemy/templates/astro/wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "website",
"main": "dist/_worker.js/index.js",
"main": "@astrojs/cloudflare/entrypoints/server",
"compatibility_date": "2025-04-20",
"assets": { "binding": "ASSETS", "directory": "dist" },
"assets": { "binding": "ASSETS", "directory": "dist/client" },
}
Loading
Loading