From a90058ba3bf5d4887f54d7c50ddcf28ff5b4a86b Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 13 Sep 2023 14:31:15 -0400 Subject: [PATCH 1/7] Change functionPerRoute to false by default --- .changeset/cool-pianos-smell.md | 9 +++++++++ packages/integrations/vercel/README.md | 8 +++++--- packages/integrations/vercel/src/serverless/adapter.ts | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changeset/cool-pianos-smell.md diff --git a/.changeset/cool-pianos-smell.md b/.changeset/cool-pianos-smell.md new file mode 100644 index 000000000000..0dec2833d9ba --- /dev/null +++ b/.changeset/cool-pianos-smell.md @@ -0,0 +1,9 @@ +--- +'@astrojs/vercel': major +--- + +Turn off functionPerRoute by default + +In `@astrojs/vercel` the default for `functionPerRoute` was changed to `true`. While this option has several advantages, if you a free tier user you are likely to run into the limit of 12 functions per deployment. This will result in an error when you attempt to deploy. + +For this reason, the `functionPerRoute` option is not back to defaulting to `false`. It's still a useful option if you have a paid plan and have run into issues with your single function exceeding the size limits. diff --git a/packages/integrations/vercel/README.md b/packages/integrations/vercel/README.md index db3a52a03f0e..8ed3a4fd21f6 100644 --- a/packages/integrations/vercel/README.md +++ b/packages/integrations/vercel/README.md @@ -238,9 +238,11 @@ export default defineConfig({ ### Function bundling configuration -The Vercel adapter splits builds into a separate function per route by default. This helps reduce the size of each function, as it only bundles code used on that page. +The Vercel adapter combines all of your routes into a single function by default. -You can disable this and build to a single function by setting the `functionPerRoute` configuration option to `false`: +You also have the option to split into a seperate function for each route using the `functionPerRoute` option. Doing so means your functions are smaller, you're less likely to exceed the size limit, and code starts are faster. + +The free tier of Vercel limits each deployment to no more than 12 functions. If you have a paid plan, using turning on `functionPerRoute` is something to consider enabling. ```js // astro.config.mjs @@ -250,7 +252,7 @@ import vercel from '@astrojs/vercel/serverless'; export default defineConfig({ output: 'server', adapter: vercel({ - functionPerRoute: false, + functionPerRoute: true, }), }); ``` diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index 22785abf596a..2bc883c409c4 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -81,7 +81,7 @@ export default function vercelServerless({ imageService, imagesConfig, devImageService = 'sharp', - functionPerRoute = true, + functionPerRoute = false, edgeMiddleware = false, }: VercelServerlessConfig = {}): AstroIntegration { let _config: AstroConfig; From 2de0774c9bb3cd2c81356ff0a7c598c418a19341 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 13 Sep 2023 16:54:34 -0400 Subject: [PATCH 2/7] Update test that depends on functionPerRoute --- .../fixtures/serverless-with-dynamic-routes/astro.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/astro.config.mjs b/packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/astro.config.mjs index f5a86e609939..da708f049b6a 100644 --- a/packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/astro.config.mjs +++ b/packages/integrations/vercel/test/fixtures/serverless-with-dynamic-routes/astro.config.mjs @@ -5,6 +5,7 @@ export default defineConfig({ adapter: vercel({ // Pass some value to make sure it doesn't error out includeFiles: ['included.js'], + functionPerRoute: true, }), output: 'server' }); From 5ede33a36593f601cc85b9ce057f112666fe0cd2 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 13 Sep 2023 17:46:34 -0400 Subject: [PATCH 3/7] Update .changeset/cool-pianos-smell.md Co-authored-by: Sarah Rainsberger --- .changeset/cool-pianos-smell.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/cool-pianos-smell.md b/.changeset/cool-pianos-smell.md index 0dec2833d9ba..863e9763e2a0 100644 --- a/.changeset/cool-pianos-smell.md +++ b/.changeset/cool-pianos-smell.md @@ -4,6 +4,6 @@ Turn off functionPerRoute by default -In `@astrojs/vercel` the default for `functionPerRoute` was changed to `true`. While this option has several advantages, if you a free tier user you are likely to run into the limit of 12 functions per deployment. This will result in an error when you attempt to deploy. +In the previous version of `@astrojs/vercel`, the default for `functionPerRoute` was changed to `true`. While this option has several advantages, if you a free tier user you are likely to run into the limit of 12 functions per deployment. This will result in an error when you attempt to deploy. -For this reason, the `functionPerRoute` option is not back to defaulting to `false`. It's still a useful option if you have a paid plan and have run into issues with your single function exceeding the size limits. +For this reason, the `functionPerRoute` option is now back to defaulting to `false`. It's still a useful option if you have a paid plan and have previously run into issues with your single function exceeding the size limits. From 4e8d64e69235ea38176ed22e19950a3e336e833b Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 13 Sep 2023 17:46:39 -0400 Subject: [PATCH 4/7] Update .changeset/cool-pianos-smell.md Co-authored-by: Sarah Rainsberger --- .changeset/cool-pianos-smell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/cool-pianos-smell.md b/.changeset/cool-pianos-smell.md index 863e9763e2a0..3b1bf1de42a0 100644 --- a/.changeset/cool-pianos-smell.md +++ b/.changeset/cool-pianos-smell.md @@ -2,7 +2,7 @@ '@astrojs/vercel': major --- -Turn off functionPerRoute by default +Turn off `functionPerRoute` by default In the previous version of `@astrojs/vercel`, the default for `functionPerRoute` was changed to `true`. While this option has several advantages, if you a free tier user you are likely to run into the limit of 12 functions per deployment. This will result in an error when you attempt to deploy. From 9cdfab97387f2c3cb84f23c91d4f7de04490f205 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 13 Sep 2023 17:46:53 -0400 Subject: [PATCH 5/7] Update packages/integrations/vercel/README.md Co-authored-by: Sarah Rainsberger --- packages/integrations/vercel/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/vercel/README.md b/packages/integrations/vercel/README.md index 8ed3a4fd21f6..863ec606242f 100644 --- a/packages/integrations/vercel/README.md +++ b/packages/integrations/vercel/README.md @@ -242,7 +242,7 @@ The Vercel adapter combines all of your routes into a single function by default You also have the option to split into a seperate function for each route using the `functionPerRoute` option. Doing so means your functions are smaller, you're less likely to exceed the size limit, and code starts are faster. -The free tier of Vercel limits each deployment to no more than 12 functions. If you have a paid plan, using turning on `functionPerRoute` is something to consider enabling. +Verify that your Vercel plan includes an appropriate number of functions before enabling `functionPerRoute`. For example, Vercel's free tier limits each deployment to no more than 12 functions. If your Vercel plan is insufficient for the number of routes in your project, you will receive an error message during deployment. ```js // astro.config.mjs From 9ab9330088bf1266cacf66ef03f97ccc93338583 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 13 Sep 2023 17:47:08 -0400 Subject: [PATCH 6/7] Update packages/integrations/vercel/README.md Co-authored-by: Sarah Rainsberger --- packages/integrations/vercel/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/vercel/README.md b/packages/integrations/vercel/README.md index 863ec606242f..cac9fcb2de48 100644 --- a/packages/integrations/vercel/README.md +++ b/packages/integrations/vercel/README.md @@ -240,7 +240,7 @@ export default defineConfig({ The Vercel adapter combines all of your routes into a single function by default. -You also have the option to split into a seperate function for each route using the `functionPerRoute` option. Doing so means your functions are smaller, you're less likely to exceed the size limit, and code starts are faster. +You also have the option to split builds into a separate function for each route using the `functionPerRoute` option. This reduces the size of each function, meaning you are less likely to exceed the size limit for an individual function. Also, code starts are faster. Verify that your Vercel plan includes an appropriate number of functions before enabling `functionPerRoute`. For example, Vercel's free tier limits each deployment to no more than 12 functions. If your Vercel plan is insufficient for the number of routes in your project, you will receive an error message during deployment. From 94ab1e25d0d74e9b3f3b42f594afc2ee6b055723 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 14 Sep 2023 08:01:13 -0400 Subject: [PATCH 7/7] Update .changeset/cool-pianos-smell.md --- .changeset/cool-pianos-smell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/cool-pianos-smell.md b/.changeset/cool-pianos-smell.md index 3b1bf1de42a0..6b222637a15a 100644 --- a/.changeset/cool-pianos-smell.md +++ b/.changeset/cool-pianos-smell.md @@ -4,6 +4,6 @@ Turn off `functionPerRoute` by default -In the previous version of `@astrojs/vercel`, the default for `functionPerRoute` was changed to `true`. While this option has several advantages, if you a free tier user you are likely to run into the limit of 12 functions per deployment. This will result in an error when you attempt to deploy. +In the previous version of `@astrojs/vercel`, the default for `functionPerRoute` was changed to `true`. While this option has several advantages, if you're a free tier user you are likely to run into the limit of 12 functions per deployment. This will result in an error when you attempt to deploy. For this reason, the `functionPerRoute` option is now back to defaulting to `false`. It's still a useful option if you have a paid plan and have previously run into issues with your single function exceeding the size limits.