Skip to content

Commit

Permalink
Remove the Vercel Edge adapter (#8015)
Browse files Browse the repository at this point in the history
* Remove the Vercel Edge adapter

* Update tests

* Update .changeset/plenty-keys-add.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Show enabling edge middleware

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
matthewp and sarah11918 authored Aug 10, 2023
1 parent 34cb200 commit 9cc4e48
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 237 deletions.
23 changes: 23 additions & 0 deletions .changeset/plenty-keys-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@astrojs/vercel': major
---

Remove the Vercel Edge adapter

`@astrojs/vercel/serverless` now supports Edge middleware, so a separate adapter for Edge itself (deploying your entire app to the edge) is no longer necessary. Please update your Astro config to reflect this change:

```diff
// astro.config.mjs
import { defineConfig } from 'astro/config';
- import vercel from '@astrojs/vercel/edge';
+ import vercel from '@astrojs/vercel/serverless';

export default defineConfig({
output: 'server',
adapter: vercel({
+ edgeMiddleware: true
}),
});
```

This adapter had several known limitations and compatibility issues that prevented many people from using it in production. To reduce maintenance costs and because we have a better story with Serveless + Edge Middleware, we are removing the Edge adapter.
15 changes: 4 additions & 11 deletions packages/integrations/vercel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ If you prefer to install the adapter manually instead, complete the following tw

You can deploy to different targets:

- `edge`: SSR inside an [Edge function](https://vercel.com/docs/concepts/functions/edge-functions).
- `serverless`: SSR inside a [Node.js function](https://vercel.com/docs/concepts/functions/serverless-functions).
- `static`: generates a static website following Vercel's output formats, redirects, etc.

> **Note**: deploying to the Edge has [its limitations](https://vercel.com/docs/concepts/functions/edge-functions#known-limitations). An edge function can't be more than 1 MB in size and they don't support native Node.js APIs, among others.
You can change where to target by changing the import:

```js
import vercel from '@astrojs/vercel/edge';
import vercel from '@astrojs/vercel/serverless';
import vercel from '@astrojs/vercel/static';
```
Expand All @@ -90,7 +86,7 @@ To configure this adapter, pass an object to the `vercel()` function call in `as
### analytics

**Type:** `boolean`<br>
**Available for:** Serverless, Edge, Static<br>
**Available for:** Serverless, Static<br>
**Added in:** `@astrojs/vercel@3.1.0`

You can enable [Vercel Analytics](https://vercel.com/analytics) (including Web Vitals and Audiences) by setting `analytics: true`. This will inject Vercel’s tracking scripts into all your pages.
Expand All @@ -111,7 +107,7 @@ export default defineConfig({
### imagesConfig

**Type:** `VercelImageConfig`<br>
**Available for:** Edge, Serverless, Static
**Available for:** Serverless, Static
**Added in:** `@astrojs/vercel@3.3.0`

Configuration options for [Vercel's Image Optimization API](https://vercel.com/docs/concepts/image-optimization). See [Vercel's image configuration documentation](https://vercel.com/docs/build-output-api/v3/configuration#images) for a complete list of supported parameters.
Expand All @@ -134,7 +130,7 @@ export default defineConfig({
### imageService

**Type:** `boolean`<br>
**Available for:** Edge, Serverless, Static
**Available for:** Serverless, Static
**Added in:** `@astrojs/vercel@3.3.0`

When enabled, an [Image Service](https://docs.astro.build/en/reference/image-service-reference/) powered by the Vercel Image Optimization API will be automatically configured and used in production. In development, a built-in Squoosh-based service will be used instead.
Expand Down Expand Up @@ -175,7 +171,7 @@ import astroLogo from '../assets/logo.png';
### includeFiles

**Type:** `string[]`<br>
**Available for:** Edge, Serverless
**Available for:** Serverless

Use this property to force files to be bundled with your function. This is helpful when you notice missing files.

Expand All @@ -192,9 +188,6 @@ export default defineConfig({
});
```

> **Note**
> When building for the Edge, all the dependencies get bundled in a single file to save space. **No extra file will be bundled**. So, if you _need_ some file inside the function, you have to specify it in `includeFiles`.
### excludeFiles

**Type:** `string[]`<br>
Expand Down
182 changes: 0 additions & 182 deletions packages/integrations/vercel/src/edge/adapter.ts

This file was deleted.

28 changes: 0 additions & 28 deletions packages/integrations/vercel/src/edge/entrypoint.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/integrations/vercel/src/edge/shim.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/integrations/vercel/test/static-assets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,4 @@ describe('Static Assets', () => {
checkValidCacheControl(assets);
});
});

describe('edge adapter', async () => {
const adapter = await import('@astrojs/vercel/edge');

it('has cache control', async () => {
await build({ adapter });
checkValidCacheControl();
});

it('has cache control other assets', async () => {
const assets = '_foo';
await build({ adapter, assets });
checkValidCacheControl(assets);
});
});
});

0 comments on commit 9cc4e48

Please sign in to comment.