Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vercel): add functions config #976

Merged
merged 5 commits into from
Feb 22, 2023

Conversation

smaeda-ks
Copy link
Contributor

Currently, some serverless function options are not customizable, such as memory and maxDuration:
https://vercel.com/docs/build-output-api/v3#vercel-primitives/serverless-functions/configuration

This PR adds support so users can optionally set those options in their nitro.config.ts file:

// nitro.config.ts
import { defineNitroConfig } from 'nitropack'
export default defineNitroConfig({
  "vercel": {
        "functions": {
            "memory": 1024,
            "maxDuration": 10,
        }
    }
})

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0
Copy link
Member

pi0 commented Feb 22, 2023

This is nice addition thanks! Any reason we don' allow specify all function configurations?

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Merging #976 (7e19ec1) into main (7efa31f) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #976      +/-   ##
==========================================
+ Coverage   67.77%   67.79%   +0.02%     
==========================================
  Files          60       60              
  Lines        6128     6132       +4     
  Branches      689      691       +2     
==========================================
+ Hits         4153     4157       +4     
  Misses       1966     1966              
  Partials        9        9              
Impacted Files Coverage Ξ”
src/presets/vercel.ts 76.92% <100.00%> (+0.40%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/presets/vercel.ts Outdated Show resolved Hide resolved
@smaeda-ks
Copy link
Contributor Author

This is nice addition thanks! Any reason we don' allow specify all function configurations?

@pi0 Thanks for asking! Other options such as environment and regions should be managed in the project settings:
https://vercel.com/docs/concepts/projects/project-configuration#env

We recommend against using this property. To add custom Environment Variables to your Project define them in the Project Settings.

So adding memory and maxDuration would be enough, I believe.

@pi0 pi0 merged commit 4585ca8 into unjs:main Feb 22, 2023
@pi0
Copy link
Member

pi0 commented Feb 22, 2023

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants