presets(vercel): allow overriding function config by route#4174
presets(vercel): allow overriding function config by route#4174
Conversation
Backport of #4124 (589e8ad) to v2. Adds `vercel.functionRules` option for per-route serverless function configuration overrides. Routes matching functionRules get copied function directories (instead of symlinks) with merged .vc-config.json. Includes auto-derived consumer names for queue/v2beta triggers.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Restore spread order so `handler`/`launcherType` can't be overridden - Skip `functionRules` config.json routes that overlap with ISR rules - Fix `defu` array merge to fully replace arrays from overrides - Normalize leading slash on `functionRules` pattern keys - Add test for ISR + functionRules config merge
commit: |
- use original route pattern (not regex) for radix3 matching in o11y loop - deduplicate functionRules routes against o11y routes in config.json - rename misleading `isrFuncDirs` variable to `isrBasePaths` - add wildcard functionRules test covering o11y route code path
Summary
Backport of 589e8ad (#4124) to v2.
Adds
vercel.functionRulesoption for per-route serverless function configuration overrides. Routes matchingfunctionRulesget copied function directories (instead of symlinks) with merged.vc-config.json. Includes auto-derived consumer names forqueue/v2betatriggers.Usage
Regression fixes
handler,launcherType,shouldAddHelpers,supportsResponseStreamingare now enforced after the user spread, so they can't be accidentally overridden viavercel.functionsfunctionRulespatterns that overlap with ISR route rules are excluded fromconfig.jsonroutes, preventing ISR from being silently bypasseddefumerges arrays by default — overrides with array fields (e.g.experimentalTriggers) now fully replace the base config arrays instead of mergingfunctionRulespattern keys are normalized with a leading/to prevent broken output fromnormalizeRouteDest/normalizeRouteSrcfunctionRulesoverrides (e.g.regions) viacreateFunctionDirWithCustomConfigfunctionRuleswildcards correctly apply to dynamic observability routesfunctionRulesroutes that already appear in observability routes are deduplicated inconfig.jsonTest plan
functionRulesoverrides (regions)functionRulesapply to observability route directories (/api/storage/**→/api/storage/dev.func)