diff --git a/.changeset/stupid-cheetahs-sell.md b/.changeset/stupid-cheetahs-sell.md new file mode 100644 index 000000000000..25edd567e1dc --- /dev/null +++ b/.changeset/stupid-cheetahs-sell.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vercel': minor +--- + +Adds support for Node 20 (currently in `beta` on Vercel). diff --git a/packages/integrations/vercel/README.md b/packages/integrations/vercel/README.md index 9f25c25539d9..9c80eae4bcb7 100644 --- a/packages/integrations/vercel/README.md +++ b/packages/integrations/vercel/README.md @@ -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`. diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index ef2552cc173f..26e33663a752 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -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({ @@ -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.`