summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/integrations/cloudflare/CHANGELOG.md96
-rw-r--r--packages/integrations/cloudflare/README.md30
-rw-r--r--packages/integrations/cloudflare/package.json14
-rw-r--r--packages/integrations/cloudflare/src/index.ts42
-rw-r--r--packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs2
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/astro.config.mjs15
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/package.json (renamed from packages/integrations/cloudflare/test/fixtures/split/package.json)2
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/middleware.ts (renamed from packages/integrations/cloudflare/test/fixtures/split/src/middleware.ts)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/[language]/files/[...path].astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/[language]/files/[...path].astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/[person]/[car].astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/[person]/[car].astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/blog/[post].astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/blog/[post].astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/blog/cool.astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/blog/cool.astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/files/[...path].astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/files/[...path].astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/index.astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/index.astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/javascript.js (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/javascript.js)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/prerender.astro (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/prerender.astro)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/test.json.ts (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/test.json.ts)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/trpc/[trpc].ts (renamed from packages/integrations/cloudflare/test/fixtures/split/src/pages/trpc/[trpc].ts)0
-rw-r--r--packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json2
-rw-r--r--packages/integrations/cloudflare/test/function-per-route.test.js (renamed from packages/integrations/cloudflare/test/directory-split.test.js)18
-rw-r--r--packages/integrations/cloudflare/test/prerender.test.js4
-rw-r--r--packages/integrations/cloudflare/test/routesJson.js6
-rw-r--r--packages/integrations/cloudflare/tsconfig.json2
23 files changed, 190 insertions, 43 deletions
diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md
index 2a53e71bd..ebbfba40c 100644
--- a/packages/integrations/cloudflare/CHANGELOG.md
+++ b/packages/integrations/cloudflare/CHANGELOG.md
@@ -1,5 +1,101 @@
# @astrojs/cloudflare
+## 7.0.0-rc.3
+
+### Major Changes
+
+- [#8179](https://github.com/withastro/astro/pull/8179) [`6011d52d3`](https://github.com/withastro/astro/commit/6011d52d38e43c3e3d52bc3bc41a60e36061b7b7) Thanks [@matthewp](https://github.com/matthewp)! - Astro 3.0 Release Candidate
+
+### Patch Changes
+
+- Updated dependencies [[`adf9fccfd`](https://github.com/withastro/astro/commit/adf9fccfdda107c2224558f1c2e6a77847ac0a8a), [`582132328`](https://github.com/withastro/astro/commit/5821323285646aee7ff9194a505f708028e4db57), [`81545197a`](https://github.com/withastro/astro/commit/81545197a32fd015d763fc386c8b67e0e08b7393), [`6011d52d3`](https://github.com/withastro/astro/commit/6011d52d38e43c3e3d52bc3bc41a60e36061b7b7), [`be6bbd2c8`](https://github.com/withastro/astro/commit/be6bbd2c86b9bf5268e765bb937dda00ff15781a), [`42785c7b7`](https://github.com/withastro/astro/commit/42785c7b784b151e6d582570e5d74482129e8eb8), [`95120efbe`](https://github.com/withastro/astro/commit/95120efbe817163663492181cbeb225849354493), [`2ae9d37f0`](https://github.com/withastro/astro/commit/2ae9d37f0a9cb21ab288d3c30aecb6d84db87788), [`f003e7364`](https://github.com/withastro/astro/commit/f003e7364317cafdb8589913b26b28e928dd07c9), [`732111cdc`](https://github.com/withastro/astro/commit/732111cdce441639db31f40f621df48442d00969), [`33b8910cf`](https://github.com/withastro/astro/commit/33b8910cfdce5713891c50a84a0a8fe926311710), [`e79e3779d`](https://github.com/withastro/astro/commit/e79e3779df0ad35253abcdb931d622847d9adb12), [`179796405`](https://github.com/withastro/astro/commit/179796405e053b559d83f84507e5a465861a029a), [`a87cbe400`](https://github.com/withastro/astro/commit/a87cbe400314341d5f72abf86ea264e6b47c091f), [`767eb6866`](https://github.com/withastro/astro/commit/767eb68666eb777965baa0d6ade20bbafecf95bf)]:
+ - astro@3.0.0-rc.5
+ - @astrojs/underscore-redirects@0.3.0-rc.1
+
+## 7.0.0-beta.2
+
+### Major Changes
+
+- [#8078](https://github.com/withastro/astro/pull/8078) [`2540feedb`](https://github.com/withastro/astro/commit/2540feedb06785d5a20eecc3668849f147d778d4) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - The configuration `build.split` and `build.excludeMiddleware` are deprecated.
+
+ You can now configure this behavior using `functionPerRoute` in your Cloudflare integration config:
+
+ ```diff
+ import {defineConfig} from "astro/config";
+ import cloudflare from '@astrojs/cloudflare';
+
+ export default defineConfig({
+ - build: {
+ - split: true
+ - },
+ - adapter: cloudflare()
+ + adapter: cloudflare({
+ + mode: 'directory',
+ + functionPerRoute: true
+ + })
+ })
+ ```
+
+### Patch Changes
+
+- [#8079](https://github.com/withastro/astro/pull/8079) [`7b77b34ce`](https://github.com/withastro/astro/commit/7b77b34cef8b46c4d14ecf9e5fcb45fb276331ec) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Sync Astro Asset support across both modes
+
+- Updated dependencies [[`2484dc408`](https://github.com/withastro/astro/commit/2484dc4080e5cd84b9a53648a1de426d7c907be2), [`c2c71d90c`](https://github.com/withastro/astro/commit/c2c71d90c264a2524f99e0373ab59015f23ad4b1), [`7177f7579`](https://github.com/withastro/astro/commit/7177f7579b6e866f0fd895b3fd079d8ba330b1a9), [`097a8e4e9`](https://github.com/withastro/astro/commit/097a8e4e916c7df18eafdaa6c8d6ce2991c17ab6), [`dbc97b121`](https://github.com/withastro/astro/commit/dbc97b121f42583728f1cdfdbf14575fda943f5b), [`2540feedb`](https://github.com/withastro/astro/commit/2540feedb06785d5a20eecc3668849f147d778d4), [`ea7ff5177`](https://github.com/withastro/astro/commit/ea7ff5177dbcd7b2508cb1eef1b22b8ee1f47079), [`68efd4a8b`](https://github.com/withastro/astro/commit/68efd4a8b29f248397667801465b3152dc98e9a7), [`0e0fa605d`](https://github.com/withastro/astro/commit/0e0fa605d109cc91e08a1ae1cc560ea240fe631b), [`5208a3c8f`](https://github.com/withastro/astro/commit/5208a3c8fefcec7694857fb344af351f4631fc34), [`8a5b0c1f3`](https://github.com/withastro/astro/commit/8a5b0c1f3a4be6bb62db66ec70144109ff5b4c59), [`d6b494376`](https://github.com/withastro/astro/commit/d6b4943764989c0e89df2d6875cd19691566dfb3), [`4477bb41c`](https://github.com/withastro/astro/commit/4477bb41c8ed688785c545731ef5b184b629f4e5), [`3e834293d`](https://github.com/withastro/astro/commit/3e834293d47ab2761a7aa013916e8371871efb7f), [`b76c166bd`](https://github.com/withastro/astro/commit/b76c166bdd8e28683f62806aef968d1e0c3b06d9)]:
+ - astro@3.0.0-beta.3
+ - @astrojs/underscore-redirects@0.3.0-beta.0
+
+## 7.0.0-beta.1
+
+### Minor Changes
+
+- [#7846](https://github.com/withastro/astro/pull/7846) [`ea30a9d4f`](https://github.com/withastro/astro/commit/ea30a9d4f2d7a12345869e971f3051cf803dbe74) Thanks [@schummar](https://github.com/schummar)! - More efficient \_routes.json
+
+### Patch Changes
+
+- Updated dependencies [[`65c354969`](https://github.com/withastro/astro/commit/65c354969e6fe0ef6d622e8f4c545e2f717ce8c6), [`3c3100851`](https://github.com/withastro/astro/commit/3c31008519ce68b5b1b1cb23b71fbe0a2d506882), [`34cb20021`](https://github.com/withastro/astro/commit/34cb2002161ba88df6bcb72fecfd12ed867c134b), [`7bd1b86f8`](https://github.com/withastro/astro/commit/7bd1b86f85c06fdde0a1ed9146d01bac69990671), [`519a1c4e8`](https://github.com/withastro/astro/commit/519a1c4e8407c7abcb8d879b67a9f4b960652cae), [`70f34f5a3`](https://github.com/withastro/astro/commit/70f34f5a355f42526ee9e5355f3de8e510002ea2), [`0f637c71e`](https://github.com/withastro/astro/commit/0f637c71e511cb4c51712128d217a26c8eee4d40), [`866ed4098`](https://github.com/withastro/astro/commit/866ed4098edffb052239cdb26e076cf8db61b1d9), [`5b1e39ef6`](https://github.com/withastro/astro/commit/5b1e39ef6ec6dcebea96584f95d9530bd9aa715d)]:
+ - astro@3.0.0-beta.1
+ - @astrojs/underscore-redirects@0.3.0-beta.0
+
+## 7.0.0-beta.0
+
+### Major Changes
+
+- [`1eae2e3f7`](https://github.com/withastro/astro/commit/1eae2e3f7d693c9dfe91c8ccfbe606d32bf2fb81) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
+
+- [`c022a4217`](https://github.com/withastro/astro/commit/c022a4217a805d223c1494e9eda4e48bbf810388) Thanks [@Princesseuh](https://github.com/Princesseuh)! - When using an adapter that supports neither Squoosh or Sharp, Astro will now automatically use an image service that does not support processing, but still provides the other benefits of `astro:assets` such as enforcing `alt`, no CLS etc to users
+
+### Minor Changes
+
+- [`9b4f70a62`](https://github.com/withastro/astro/commit/9b4f70a629f55e461759ba46f68af7097a2e9215) Thanks [@ematipico](https://github.com/ematipico)! - Introduced the concept of feature map. A feature map is a list of features that are built-in in Astro, and an Adapter
+ can tell Astro if it can support it.
+
+ ```ts
+ import { AstroIntegration } from './astro';
+
+ function myIntegration(): AstroIntegration {
+ return {
+ name: 'astro-awesome-list',
+ // new feature map
+ supportedAstroFeatures: {
+ hybridOutput: 'experimental',
+ staticOutput: 'stable',
+ serverOutput: 'stable',
+ assets: {
+ supportKind: 'stable',
+ isSharpCompatible: false,
+ isSquooshCompatible: false,
+ },
+ },
+ };
+ }
+ ```
+
+### Patch Changes
+
+- Updated dependencies [[`1eae2e3f7`](https://github.com/withastro/astro/commit/1eae2e3f7d693c9dfe91c8ccfbe606d32bf2fb81), [`76ddef19c`](https://github.com/withastro/astro/commit/76ddef19ccab6e5f7d3a5740cd41acf10e334b38), [`9b4f70a62`](https://github.com/withastro/astro/commit/9b4f70a629f55e461759ba46f68af7097a2e9215), [`3fdf509b2`](https://github.com/withastro/astro/commit/3fdf509b2731a9b2f972d89291e57cf78d62c769), [`2f951cd40`](https://github.com/withastro/astro/commit/2f951cd403dfcc2c3ca6aae618ae3e1409516e32), [`c022a4217`](https://github.com/withastro/astro/commit/c022a4217a805d223c1494e9eda4e48bbf810388), [`67becaa58`](https://github.com/withastro/astro/commit/67becaa580b8f787df58de66b7008b7098f1209c), [`bc37331d8`](https://github.com/withastro/astro/commit/bc37331d8154e3e95a8df9131e4e014e78a7a9e7), [`dfc2d93e3`](https://github.com/withastro/astro/commit/dfc2d93e3c645995379358fabbdfa9aab99f43d8), [`3dc1ca2fa`](https://github.com/withastro/astro/commit/3dc1ca2fac8d9965cc5085a5d09e72ed87b4281a), [`1be84dfee`](https://github.com/withastro/astro/commit/1be84dfee3ce8e6f5cc624f99aec4e980f6fde37), [`35f01df79`](https://github.com/withastro/astro/commit/35f01df797d23315f2bee2fc3fd795adb0559c58), [`3fdf509b2`](https://github.com/withastro/astro/commit/3fdf509b2731a9b2f972d89291e57cf78d62c769), [`78de801f2`](https://github.com/withastro/astro/commit/78de801f21fd4ca1653950027d953bf08614566b), [`59d6e569f`](https://github.com/withastro/astro/commit/59d6e569f63e175c97e82e94aa7974febfb76f7c), [`7723c4cc9`](https://github.com/withastro/astro/commit/7723c4cc93298c2e6530e55da7afda048f22cf81), [`fb5cd6b56`](https://github.com/withastro/astro/commit/fb5cd6b56dc27a71366ed5e1ab8bfe9b8f96bac5), [`631b9c410`](https://github.com/withastro/astro/commit/631b9c410d5d66fa384674027ba95d69ebb5063f)]:
+ - astro@3.0.0-beta.0
+ - @astrojs/underscore-redirects@0.3.0-beta.0
+
## 6.8.0
### Minor Changes
diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md
index 523e7c255..25cd7c376 100644
--- a/packages/integrations/cloudflare/README.md
+++ b/packages/integrations/cloudflare/README.md
@@ -44,23 +44,37 @@ export default defineConfig({
default `"advanced"`
-Cloudflare Pages has 2 different modes for deploying functions, `advanced` mode which picks up the `_worker.js` in `dist`, or a directory mode where pages will compile the worker out of a functions folder in the project root.
+Cloudflare Pages has 2 different modes for deploying functions, `advanced` mode which picks up the `_worker.js` in `dist`, or a directory mode where pages will compile the worker out of a functions folder in the project root. For most projects the adapter default of `advanced` will be sufficient; the `dist` folder will contain your compiled project.
-For most projects the adapter default of `advanced` will be sufficient; the `dist` folder will contain your compiled project. Switching to directory mode allows you to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) or write custom code to enable logging.
+#### `mode:directory`
-In directory mode, the adapter will compile the client side part of your app the same way by default, but moves the worker script into a `functions` folder in the project root. In this case, the adapter will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control.
-
-With the build configuration `split: true`, the adapter instead compiles a separate bundle for each page. This option requires some manual maintenance of the `functions` folder. Files emitted by Astro will overwrite existing `functions` files with identical names, so you must choose unique file names for each file you manually add. Additionally, the adapter will never empty the `functions` folder of outdated files, so you must clean up the folder manually when you remove pages.
-
-Note that this adapter does not support using [Cloudflare Pages Middleware](https://developers.cloudflare.com/pages/platform/functions/middleware/). Astro will bundle the [Astro middleware](https://docs.astro.build/en/guides/middleware/) into each page.
+Switching to directory mode allows you to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) or write custom code to enable logging.
```ts
-// directory mode
+// astro.config.mjs
export default defineConfig({
adapter: cloudflare({ mode: 'directory' }),
});
```
+In `directory` mode, the adapter will compile the client-side part of your app the same way as in `advanced` mode by default, but moves the worker script into a `functions` folder in the project root. In this case, the adapter will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control.
+
+To instead compile a separate bundle for each page, set the `functionPerPath` option in your Cloudflare adapter config. This option requires some manual maintenance of the `functions` folder. Files emitted by Astro will overwrite existing `functions` files with identical names, so you must choose unique file names for each file you manually add. Additionally, the adapter will never empty the `functions` folder of outdated files, so you must clean up the folder manually when you remove pages.
+
+```diff
+import {defineConfig} from "astro/config";
+import cloudflare from '@astrojs/cloudflare';
+
+export default defineConfig({
+ adapter: cloudflare({
+ mode: 'directory',
++ functionPerRoute: true
+ })
+})
+```
+
+Note that this adapter does not support using [Cloudflare Pages Middleware](https://developers.cloudflare.com/pages/platform/functions/middleware/). Astro will bundle the [Astro middleware](https://docs.astro.build/en/guides/middleware/) into each page.
+
## Enabling Preview
In order for preview to work you must install `wrangler`
diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json
index a6c9725ae..29667f9ba 100644
--- a/packages/integrations/cloudflare/package.json
+++ b/packages/integrations/cloudflare/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/cloudflare",
"description": "Deploy your site to Cloudflare Workers/Pages",
- "version": "6.8.0",
+ "version": "7.0.0-rc.3",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
@@ -39,13 +39,13 @@
"test:match": "mocha --exit --timeout 30000 -g"
},
"dependencies": {
- "@astrojs/underscore-redirects": "^0.2.0",
- "@cloudflare/workers-types": "^4.20230518.0",
- "esbuild": "^0.17.19",
+ "@astrojs/underscore-redirects": "workspace:*",
+ "@cloudflare/workers-types": "^4.20230821.0",
+ "esbuild": "^0.19.2",
"tiny-glob": "^0.2.9"
},
"peerDependencies": {
- "astro": "workspace:^2.10.13"
+ "astro": "workspace:^3.0.0-rc.5"
},
"devDependencies": {
"astro": "workspace:*",
@@ -53,7 +53,7 @@
"chai": "^4.3.7",
"cheerio": "1.0.0-rc.12",
"kill-port": "^2.0.1",
- "mocha": "^9.2.2",
- "wrangler": "^3.5.0"
+ "mocha": "^10.2.0",
+ "wrangler": "^3.5.1"
}
}
diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts
index a0201008f..718b1efa8 100644
--- a/packages/integrations/cloudflare/src/index.ts
+++ b/packages/integrations/cloudflare/src/index.ts
@@ -12,6 +12,7 @@ export type { DirectoryRuntime } from './server.directory';
type Options = {
mode: 'directory' | 'advanced';
+ functionPerRoute?: boolean;
};
interface BuildConfig {
@@ -21,17 +22,47 @@ interface BuildConfig {
split?: boolean;
}
-export function getAdapter(isModeDirectory: boolean): AstroAdapter {
+export function getAdapter({
+ isModeDirectory,
+ functionPerRoute,
+}: {
+ isModeDirectory: boolean;
+ functionPerRoute: boolean;
+}): AstroAdapter {
return isModeDirectory
? {
name: '@astrojs/cloudflare',
serverEntrypoint: '@astrojs/cloudflare/server.directory.js',
exports: ['onRequest', 'manifest'],
+ adapterFeatures: {
+ functionPerRoute,
+ edgeMiddleware: false,
+ },
+ supportedAstroFeatures: {
+ hybridOutput: 'stable',
+ staticOutput: 'unsupported',
+ serverOutput: 'stable',
+ assets: {
+ supportKind: 'stable',
+ isSharpCompatible: false,
+ isSquooshCompatible: false,
+ },
+ },
}
: {
name: '@astrojs/cloudflare',
serverEntrypoint: '@astrojs/cloudflare/server.advanced.js',
exports: ['default'],
+ supportedAstroFeatures: {
+ hybridOutput: 'stable',
+ staticOutput: 'unsupported',
+ serverOutput: 'stable',
+ assets: {
+ supportKind: 'stable',
+ isSharpCompatible: false,
+ isSquooshCompatible: false,
+ },
+ },
};
}
@@ -50,9 +81,11 @@ const potentialFunctionRouteTypes = ['endpoint', 'page'];
export default function createIntegration(args?: Options): AstroIntegration {
let _config: AstroConfig;
let _buildConfig: BuildConfig;
- const isModeDirectory = args?.mode === 'directory';
let _entryPoints = new Map<RouteData, URL>();
+ const isModeDirectory = args?.mode === 'directory';
+ const functionPerRoute = args?.functionPerRoute ?? false;
+
return {
name: '@astrojs/cloudflare',
hooks: {
@@ -67,7 +100,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
});
},
'astro:config:done': ({ setAdapter, config }) => {
- setAdapter(getAdapter(isModeDirectory));
+ setAdapter(getAdapter({ isModeDirectory, functionPerRoute }));
_config = config;
_buildConfig = config.build;
@@ -119,7 +152,8 @@ export default function createIntegration(args?: Options): AstroIntegration {
await fs.promises.mkdir(functionsUrl, { recursive: true });
}
- if (isModeDirectory && _buildConfig.split) {
+ // TODO: remove _buildConfig.split in Astro 4.0
+ if (isModeDirectory && (_buildConfig.split || functionPerRoute)) {
const entryPointsURL = [..._entryPoints.values()];
const entryPaths = entryPointsURL.map((entry) => fileURLToPath(entry));
const outputUrl = new URL('$astro', _buildConfig.server);
diff --git a/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs
index 105247b1b..407dc4355 100644
--- a/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs
+++ b/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs
@@ -6,5 +6,5 @@ process.env.SECRET_STUFF = 'secret'
export default defineConfig({
adapter: cloudflare(),
- output: 'server',
+ output: 'server'
});
diff --git a/packages/integrations/cloudflare/test/fixtures/function-per-route/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/function-per-route/astro.config.mjs
new file mode 100644
index 000000000..aa3f3dabc
--- /dev/null
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/astro.config.mjs
@@ -0,0 +1,15 @@
+import { defineConfig } from 'astro/config';
+import cloudflare from '@astrojs/cloudflare';
+
+export default defineConfig({
+ adapter: cloudflare({
+ mode: 'directory',
+ functionPerRoute: true
+ }),
+ output: 'server',
+ vite: {
+ build: {
+ minify: false,
+ },
+ },
+});
diff --git a/packages/integrations/cloudflare/test/fixtures/split/package.json b/packages/integrations/cloudflare/test/fixtures/function-per-route/package.json
index fd7dcc253..54dded9dd 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/package.json
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/package.json
@@ -1,5 +1,5 @@
{
- "name": "@test/astro-cloudflare-split",
+ "name": "@test/astro-cloudflare-function-per-route",
"version": "0.0.0",
"private": true,
"dependencies": {
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/middleware.ts b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/middleware.ts
index a6ce640cb..a6ce640cb 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/middleware.ts
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/middleware.ts
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/[language]/files/[...path].astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/[language]/files/[...path].astro
index 84ad53228..84ad53228 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/[language]/files/[...path].astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/[language]/files/[...path].astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/[person]/[car].astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/[person]/[car].astro
index f4fda9dc5..f4fda9dc5 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/[person]/[car].astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/[person]/[car].astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/blog/[post].astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/blog/[post].astro
index 7b0e1e5b8..7b0e1e5b8 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/blog/[post].astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/blog/[post].astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/blog/cool.astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/blog/cool.astro
index 7127282a4..7127282a4 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/blog/cool.astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/blog/cool.astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/files/[...path].astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/files/[...path].astro
index 84ad53228..84ad53228 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/files/[...path].astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/files/[...path].astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/index.astro
index a7f564046..a7f564046 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/index.astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/index.astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/javascript.js b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/javascript.js
index e69de29bb..e69de29bb 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/javascript.js
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/javascript.js
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/prerender.astro b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/prerender.astro
index bdda9b12c..bdda9b12c 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/prerender.astro
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/prerender.astro
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/test.json.ts b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/test.json.ts
index e69de29bb..e69de29bb 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/test.json.ts
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/test.json.ts
diff --git a/packages/integrations/cloudflare/test/fixtures/split/src/pages/trpc/[trpc].ts b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/trpc/[trpc].ts
index e69de29bb..e69de29bb 100644
--- a/packages/integrations/cloudflare/test/fixtures/split/src/pages/trpc/[trpc].ts
+++ b/packages/integrations/cloudflare/test/fixtures/function-per-route/src/pages/trpc/[trpc].ts
diff --git a/packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json b/packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json
index df887a73a..55e344b21 100644
--- a/packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json
+++ b/packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json
@@ -6,6 +6,6 @@
"@astrojs/cloudflare": "workspace:*",
"@astrojs/solid-js": "workspace:*",
"astro": "workspace:*",
- "solid-js": "^1.7.6"
+ "solid-js": "^1.7.11"
}
}
diff --git a/packages/integrations/cloudflare/test/directory-split.test.js b/packages/integrations/cloudflare/test/function-per-route.test.js
index 6e6b0bfe2..d20b0fa7c 100644
--- a/packages/integrations/cloudflare/test/directory-split.test.js
+++ b/packages/integrations/cloudflare/test/function-per-route.test.js
@@ -1,25 +1,13 @@
import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
-import cloudflare from '../dist/index.js';
-/** @type {import('./test-utils').Fixture} */
-describe('Cloudflare SSR split', () => {
+/** @type {import('./test-utils.js').Fixture} */
+describe('Cloudflare SSR functionPerRoute', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
- root: './fixtures/split/',
- adapter: cloudflare({ mode: 'directory' }),
- output: 'server',
- build: {
- split: true,
- excludeMiddleware: false,
- },
- vite: {
- build: {
- minify: false,
- },
- },
+ root: './fixtures/function-per-route/',
});
await fixture.build();
});
diff --git a/packages/integrations/cloudflare/test/prerender.test.js b/packages/integrations/cloudflare/test/prerender.test.js
index fe0721f27..6c2b8c5bb 100644
--- a/packages/integrations/cloudflare/test/prerender.test.js
+++ b/packages/integrations/cloudflare/test/prerender.test.js
@@ -23,7 +23,7 @@ describe('Prerendering', () => {
expect(foundRoutes).to.deep.equal({
version: 1,
- include: ['/'],
+ include: ['/', '/_image'],
exclude: [],
});
});
@@ -51,7 +51,7 @@ describe('Hybrid rendering', () => {
expect(foundRoutes).to.deep.equal({
version: 1,
- include: ['/one'],
+ include: ['/one', '/_image'],
exclude: [],
});
});
diff --git a/packages/integrations/cloudflare/test/routesJson.js b/packages/integrations/cloudflare/test/routesJson.js
index 927e4c38e..1714dfb89 100644
--- a/packages/integrations/cloudflare/test/routesJson.js
+++ b/packages/integrations/cloudflare/test/routesJson.js
@@ -24,7 +24,7 @@ describe('_routes.json generation', () => {
expect(routes).to.deep.equal({
version: 1,
- include: ['/a/*'],
+ include: ['/a/*', '/_image'],
exclude: ['/a/', '/a/redirect', '/a/index.html'],
});
});
@@ -70,8 +70,8 @@ describe('_routes.json generation', () => {
expect(routes).to.deep.equal({
version: 1,
- include: ['/'],
- exclude: ['/'],
+ include: ['/_image'],
+ exclude: [],
});
});
});
diff --git a/packages/integrations/cloudflare/tsconfig.json b/packages/integrations/cloudflare/tsconfig.json
index 64d4ef454..af1b43564 100644
--- a/packages/integrations/cloudflare/tsconfig.json
+++ b/packages/integrations/cloudflare/tsconfig.json
@@ -5,6 +5,6 @@
"allowJs": true,
"module": "ES2022",
"outDir": "./dist",
- "target": "ES2021"
+ "target": "ES2022"
}
}