diff --git a/.changeset/flat-pears-hug.md b/.changeset/flat-pears-hug.md new file mode 100644 index 00000000..fcaa4d30 --- /dev/null +++ b/.changeset/flat-pears-hug.md @@ -0,0 +1,25 @@ +--- +'@astrojs/cloudflare': minor +--- + +Prepares for major breaking changes to adapter configuration in the upcoming v10 release. + +_(Full documentation to help you migrate your project to the upgraded Cloudflare adapter will be provided with the release of v10.0.)_ + +**Deprecates** the following adapter configuration options (to be **removed entirely in v10**): + +- **`mode`:** All projects will deploy to Cloudflare pages using [advanced mode](https://developers.cloudflare.com/pages/functions/advanced-mode/) (the previous default setting). This is no longer a configurable option. [Cloudflare Functions](https://developers.cloudflare.com/pages/functions/get-started/) will no longer be supported. If you were using `mode: 'directory'`, please migrate to [Astro Endpoints](https://docs.astro.build/en/guides/endpoints/). + +- **`functionPerRoute`:** Discontinued due to Cloudflare's single execution context approach. You will no longer have the option to compile a separate bundle for each page. + +- **`routes.strategy`:** Projects will use the auto-generated `_route.json` for route management unless you [provide your own `public/_routes.json`](/en/guides/integrations-guide/cloudflare/#custom-_routesjson). This change aims to eliminate confusion and promote consistency. + +- **`routes.include`:** Will be replaced by a new `routes.extend.include` option to allow you to include additional routes. + +- **`routes.exclude`:** Will be replaced by a new `routes.extend.exclude` option to allow you to exclude additional routes. + +- **`runtime`:** Local runtime bindings will be configured in `wrangler.toml` at the root of your project as described in the [adapters documentation](https://docs.astro.build/en/guides/integrations-guide/cloudflare/#cloudflare-workers). You will no longer configure these directly in the adapter configuration. A new `platformProxy` setting will be introduced to enable and configure the platformProxy (local runtime) provided by wrangler. + +These changes are part of ongoing efforts to streamline functionality, improve performance, and align with best practices and platform capabilities. + +We strongly recommend upgrading to v10 upon its release. To ensure a smooth migration, we commit to at least 4 weeks of additional maintenance for v9 following the release of v10. During this period, we will actively assist with migration efforts to ensure that all users can transition without major issues. diff --git a/packages/cloudflare/src/index.ts b/packages/cloudflare/src/index.ts index 511b8545..d27a46f7 100644 --- a/packages/cloudflare/src/index.ts +++ b/packages/cloudflare/src/index.ts @@ -21,25 +21,31 @@ import { wasmModuleLoader } from './utils/wasm-module-loader.js'; export type { AdvancedRuntime } from './entrypoints/server.advanced.js'; export type { DirectoryRuntime } from './entrypoints/server.directory.js'; export type Options = { + /** + * @deprecated Removed in v10. The 'directory' mode was discontinued because it redundantly bundles code, slowing down your site. Prefer using Astro API Endpoints over `/functions`. The new default mode is 'advanced'. + */ mode?: 'directory' | 'advanced'; + /** + * @deprecated Removed in v10. This setting is obsolete as Cloudflare handles all functions in a single execution context, negating the need for multiple functions per project. + */ functionPerRoute?: boolean; imageService?: 'passthrough' | 'cloudflare' | 'compile'; - /** Configure automatic `routes.json` generation */ routes?: { - /** Strategy for generating `include` and `exclude` patterns - * - `auto`: Will use the strategy that generates the least amount of entries. - * - `include`: For each page or endpoint in your application that is not prerendered, an entry in the `include` array will be generated. For each page that is prerendered and whoose path is matched by an `include` entry, an entry in the `exclude` array will be generated. - * - `exclude`: One `"/*"` entry in the `include` array will be generated. For each page that is prerendered, an entry in the `exclude` array will be generated. - * */ + /** + * @deprecated Removed in v10. You will have two options going forward, using auto generated `_route.json` file or provide your own one in `public/_routes.json`. The previous method caused confusion and inconsistencies. + */ strategy?: 'auto' | 'include' | 'exclude'; - /** Additional `include` patterns */ + /** + * @deprecated Removed in v10. Use `routes.extend.include` instead. + */ include?: string[]; - /** Additional `exclude` patterns */ + /** + * @deprecated Removed in v10. Use `routes.extend.exclude` instead. + */ exclude?: string[]; }; /** - * { mode: 'off' }: current behaviour (wrangler is needed) - * { mode: 'local', ... }: adds cf request object, locals bindings, env vars/secrets which are defined by the user to `astro.dev` with `Astro.locals.runtime` / `context.locals.runtime` + * @deprecated Removed in v10. Configure bindings in `wrangler.toml`. Leveraging Cloudflare's API simplifies setup and ensures full compatibility with Wrangler configurations. Use `platformProxy` instead. */ runtime?: | { mode: 'off' }