Change functionPerRoute to false by default (#8546)

* Change functionPerRoute to false by default

* Update test that depends on functionPerRoute

* Update .changeset/cool-pianos-smell.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/cool-pianos-smell.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update packages/integrations/vercel/README.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update packages/integrations/vercel/README.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/cool-pianos-smell.md

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
This commit is contained in:
Matthew Phillips 2023-09-14 20:15:11 +08:00 committed by GitHub
parent 74dc3edb30
commit b79e11f3c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View file

@ -0,0 +1,9 @@
---
'@astrojs/vercel': major
---
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'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.

View file

@ -263,9 +263,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 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.
```js
// astro.config.mjs
@ -275,7 +277,7 @@ import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercel({
functionPerRoute: false,
functionPerRoute: true,
}),
});
```

View file

@ -95,7 +95,7 @@ export default function vercelServerless({
imageService,
imagesConfig,
devImageService = 'sharp',
functionPerRoute = true,
functionPerRoute = false,
edgeMiddleware = false,
}: VercelServerlessConfig = {}): AstroIntegration {
let _config: AstroConfig;

View file

@ -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'
});