Skip to content

Commit

Permalink
chore(vercel): Add beta option for status (#9413)
Browse files Browse the repository at this point in the history
* Add beta option for status

* Create stupid-cheetahs-sell.md

* Add warning for beta

* Update packages/integrations/vercel/src/serverless/adapter.ts

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* Switch to `minor` and document new API/option

* Update README.md

* Update README.md

* Update packages/integrations/vercel/README.md

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* Update .changeset/stupid-cheetahs-sell.md

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

---------

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
  • Loading branch information
Jacob Lamb and florian-lefebvre authored Dec 13, 2023
1 parent 2c168af commit 836ab62
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-cheetahs-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': minor
---

Adds support for Node 20 (currently in `beta` on Vercel).
6 changes: 6 additions & 0 deletions packages/integrations/vercel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ When you opt in to this feature, there are few constraints to note:
- Only `request` and `context` may be used to produce an `Astro.locals` object. Operations like redirects, etc. should be delegated to Astro middleware.
- `Astro.locals` **must be serializable**. Failing to do so will result in a **runtime error**. This means that you **cannot** store complex types like `Map`, `function`, `Set`, etc.

### Node.js Version Support

The `@astrojs/vercel` adapter supports specific Node.js versions for deploying your Astro project on Vercel. To view the supported Node.js versions on Vercel, click on the settings tab for a project and scroll down to "Node.js Version" section.

Check out the [Vercel documentation](https://vercel.com/docs/functions/serverless-functions/runtimes/node-js#default-and-available-versions) to learn more.

## Troubleshooting

**A few known complex packages (example: [puppeteer](https://github.com/puppeteer/puppeteer)) do not support bundling and therefore will not work properly with this adapter.** By default, Vercel doesn't include npm installed files & packages from your project's `./node_modules` folder. To address this, the `@astrojs/vercel` adapter automatically bundles your final build output using `esbuild`.
Expand Down
11 changes: 9 additions & 2 deletions packages/integrations/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export const VERCEL_EDGE_MIDDLEWARE_FILE = 'vercel-edge-middleware';
// https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version
const SUPPORTED_NODE_VERSIONS: Record<
string,
{ status: 'current' } | { status: 'deprecated'; removal: Date }
{ status: 'current' } | { status: 'beta' } | { status: 'deprecated'; removal: Date }
> = {
14: { status: 'deprecated', removal: new Date('August 15 2023') },
16: { status: 'deprecated', removal: new Date('February 6 2024') },
18: { status: 'current' },
20: { status: 'beta' },
};

function getAdapter({
Expand Down Expand Up @@ -377,6 +377,13 @@ function validateRuntime() {
const version = process.version.slice(1); // 'v16.5.0' --> '16.5.0'
const major = version.split('.')[0]; // '16.5.0' --> '16'
const support = SUPPORTED_NODE_VERSIONS[major];
if (support.status === 'beta') {
console.warn(
`[${PACKAGE_NAME}] The local Node.js version (${major}) is currently in beta for Vercel Serverless Functions.`
);
console.warn(`[${PACKAGE_NAME}] Make sure to update your Vercel settings to use ${major}.`);
return;
}
if (support === undefined) {
console.warn(
`[${PACKAGE_NAME}] The local Node.js version (${major}) is not supported by Vercel Serverless Functions.`
Expand Down

0 comments on commit 836ab62

Please sign in to comment.