summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jacob Lamb <jacobtlamb@hey.com> 2023-12-13 04:12:48 -0800
committerGravatar GitHub <noreply@github.com> 2023-12-13 12:12:48 +0000
commit836ab6214e5ef778ef2db2c079f49e87ce70d711 (patch)
tree0eb98b667b55101e6150b6c724d1a830d35f5e5b
parent2c168af6745f5357e76ec323787595ef06d5fd73 (diff)
downloadastro-836ab6214e5ef778ef2db2c079f49e87ce70d711.tar.gz
astro-836ab6214e5ef778ef2db2c079f49e87ce70d711.tar.zst
astro-836ab6214e5ef778ef2db2c079f49e87ce70d711.zip
chore(vercel): Add beta option for status (#9413)
* 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>
-rw-r--r--.changeset/stupid-cheetahs-sell.md5
-rw-r--r--packages/integrations/vercel/README.md6
-rw-r--r--packages/integrations/vercel/src/serverless/adapter.ts11
3 files changed, 20 insertions, 2 deletions
diff --git a/.changeset/stupid-cheetahs-sell.md b/.changeset/stupid-cheetahs-sell.md
new file mode 100644
index 000000000..25edd567e
--- /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 9f25c2553..9c80eae4b 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 ef2552cc1..26e33663a 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.`