From d0e513f214fe3cb30bab6d98936cda796477f2f8 Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Mon, 18 Sep 2023 16:52:55 +0530 Subject: [PATCH] fix: Vercel serverless adapter logs too much (#8581) --- .changeset/fluffy-dodos-rule.md | 5 +++++ .../integrations/vercel/src/serverless/adapter.ts | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changeset/fluffy-dodos-rule.md diff --git a/.changeset/fluffy-dodos-rule.md b/.changeset/fluffy-dodos-rule.md new file mode 100644 index 000000000000..7ec2f5bcc837 --- /dev/null +++ b/.changeset/fluffy-dodos-rule.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vercel': patch +--- + +log only once in serverless adapter diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index 88887fd3a6c1..de6ddb83ea40 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -245,6 +245,8 @@ You can set functionPerRoute: false to prevent surpassing the limit.` const filesToInclude = includeFiles?.map((file) => new URL(file, _config.root)) || []; filesToInclude.push(...extraFilesToInclude); + validateRuntime(); + // Multiple entrypoint support if (_entryPoints.size) { const getRouteFuncName = (route: RouteData) => route.component.replace('src/pages/', ''); @@ -312,7 +314,7 @@ You can set functionPerRoute: false to prevent surpassing the limit.` }; } -function getRuntime() { +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]; @@ -322,7 +324,7 @@ function getRuntime() { ); console.warn(`[${PACKAGE_NAME}] Your project will use Node.js 18 as the runtime instead.`); console.warn(`[${PACKAGE_NAME}] Consider switching your local version to 18.`); - return 'nodejs18.x'; + return; } if (support.status === 'deprecated') { console.warn( @@ -336,5 +338,14 @@ function getRuntime() { ); console.warn(`[${PACKAGE_NAME}] Consider upgrading your local version to 18.`); } +} + +function getRuntime() { + 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 === undefined) { + return 'nodejs18.x'; + } return `nodejs${major}.x`; }