Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(vercel): Add beta option for status #9413

Merged
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
Loading