@vercel/config 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/router.js +59 -3
- package/dist/types.d.ts +154 -0
- package/dist/types.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ router.redirect('/old-docs', '/docs', { permanent: true });
|
|
|
34
34
|
// Cache control
|
|
35
35
|
router.cacheControl('/static/(.*)', {
|
|
36
36
|
public: true,
|
|
37
|
-
maxAge: '
|
|
37
|
+
maxAge: '1 week',
|
|
38
38
|
immutable: true
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -118,7 +118,7 @@ Set cache control headers. Options include `public`, `private`, `maxAge`, `sMaxA
|
|
|
118
118
|
```typescript
|
|
119
119
|
router.cacheControl('/static/(.*)', {
|
|
120
120
|
public: true,
|
|
121
|
-
maxAge: '
|
|
121
|
+
maxAge: '1 week',
|
|
122
122
|
immutable: true
|
|
123
123
|
});
|
|
124
124
|
```
|
package/dist/cli.js
CHANGED
|
@@ -37,10 +37,9 @@ const ROUTE_BASED_EXPORTS = new Set([
|
|
|
37
37
|
'redirects',
|
|
38
38
|
'rewrites',
|
|
39
39
|
'headers',
|
|
40
|
-
'crons',
|
|
41
40
|
'env',
|
|
42
41
|
'cacheControl',
|
|
43
|
-
'__esModule'
|
|
42
|
+
'__esModule'
|
|
44
43
|
]);
|
|
45
44
|
/**
|
|
46
45
|
* Read the user's vercel.ts file and collect both default export and export const declarations
|
package/dist/index.d.ts
CHANGED
package/dist/router.js
CHANGED
|
@@ -607,11 +607,67 @@ class Router {
|
|
|
607
607
|
});
|
|
608
608
|
// Combine with existing routes
|
|
609
609
|
const allRoutes = [...routesFromRewrites, ...this.routeRules];
|
|
610
|
-
// If routes exist,
|
|
610
|
+
// If routes exist, convert everything to routes format
|
|
611
|
+
// Vercel doesn't allow mixing routes with redirects, rewrites, headers, cleanUrls, or trailingSlash
|
|
611
612
|
if (allRoutes.length > 0) {
|
|
613
|
+
// Convert standalone redirects to routes
|
|
614
|
+
const routesFromRedirects = this.redirectRules.map(redirectRule => {
|
|
615
|
+
const route = {
|
|
616
|
+
src: redirectRule.source,
|
|
617
|
+
dest: redirectRule.destination,
|
|
618
|
+
redirect: true,
|
|
619
|
+
status: redirectRule.statusCode || (redirectRule.permanent ? 308 : 307),
|
|
620
|
+
};
|
|
621
|
+
if (redirectRule.has)
|
|
622
|
+
route.has = redirectRule.has;
|
|
623
|
+
if (redirectRule.missing)
|
|
624
|
+
route.missing = redirectRule.missing;
|
|
625
|
+
return route;
|
|
626
|
+
});
|
|
627
|
+
// Convert legacy rewrites (without transforms) to routes
|
|
628
|
+
const routesFromLegacyRewrites = legacyRewrites.map(rewrite => {
|
|
629
|
+
const route = {
|
|
630
|
+
src: rewrite.source,
|
|
631
|
+
dest: rewrite.destination,
|
|
632
|
+
};
|
|
633
|
+
if (rewrite.has)
|
|
634
|
+
route.has = rewrite.has;
|
|
635
|
+
if (rewrite.missing)
|
|
636
|
+
route.missing = rewrite.missing;
|
|
637
|
+
return route;
|
|
638
|
+
});
|
|
639
|
+
// Convert standalone headers to routes (except rewrite caching headers)
|
|
640
|
+
const routesFromHeaders = this.headerRules
|
|
641
|
+
.filter(rule => {
|
|
642
|
+
// Exclude rewrite caching headers (they're automatically added for rewrites)
|
|
643
|
+
const isCachingHeader = rule.headers.length === 1 &&
|
|
644
|
+
rule.headers[0].key === 'x-vercel-enable-rewrite-caching';
|
|
645
|
+
return !isCachingHeader;
|
|
646
|
+
})
|
|
647
|
+
.map(headerRule => {
|
|
648
|
+
const transforms = headerRule.headers.map(header => ({
|
|
649
|
+
type: 'response.headers',
|
|
650
|
+
op: 'set',
|
|
651
|
+
target: { key: header.key },
|
|
652
|
+
args: header.value,
|
|
653
|
+
}));
|
|
654
|
+
const route = {
|
|
655
|
+
src: headerRule.source,
|
|
656
|
+
transforms,
|
|
657
|
+
};
|
|
658
|
+
if (headerRule.has)
|
|
659
|
+
route.has = headerRule.has;
|
|
660
|
+
if (headerRule.missing)
|
|
661
|
+
route.missing = headerRule.missing;
|
|
662
|
+
return route;
|
|
663
|
+
});
|
|
664
|
+
// Combine all routes: redirects, legacy rewrites, rewrites with transforms, explicit routes, and headers as routes
|
|
665
|
+
const combinedRoutes = [...routesFromRedirects, ...routesFromLegacyRewrites, ...routesFromRewrites, ...this.routeRules, ...routesFromHeaders];
|
|
612
666
|
const config = {
|
|
613
|
-
routes:
|
|
667
|
+
routes: combinedRoutes,
|
|
614
668
|
};
|
|
669
|
+
// NOTE: crons are now handled via export const crons in vercel.ts
|
|
670
|
+
// They are no longer included in router.getConfig()
|
|
615
671
|
// Only include optional fields if they're explicitly set
|
|
616
672
|
if (this.bulkRedirectsPathConfig !== undefined) {
|
|
617
673
|
config.bulkRedirectsPath = this.bulkRedirectsPathConfig;
|
|
@@ -631,7 +687,7 @@ class Router {
|
|
|
631
687
|
rewrites: legacyRewrites,
|
|
632
688
|
cleanUrls: this.cleanUrlsConfig,
|
|
633
689
|
trailingSlash: this.trailingSlashConfig,
|
|
634
|
-
|
|
690
|
+
// NOTE: crons are now handled via export const crons in vercel.ts
|
|
635
691
|
};
|
|
636
692
|
// Only include optional fields if they're explicitly set
|
|
637
693
|
if (this.bulkRedirectsPathConfig !== undefined) {
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel configuration type that mirrors the vercel.json schema
|
|
3
|
+
* https://openapi.vercel.sh/vercel.json
|
|
4
|
+
*/
|
|
5
|
+
export type Framework = 'blitzjs' | 'nextjs' | 'gatsby' | 'remix' | 'react-router' | 'astro' | 'hexo' | 'eleventy' | 'docusaurus-2' | 'docusaurus' | 'preact' | 'solidstart-1' | 'solidstart' | 'dojo' | 'ember' | 'vue' | 'scully' | 'ionic-angular' | 'angular' | 'polymer' | 'svelte' | 'sveltekit' | 'sveltekit-1' | 'ionic-react' | 'create-react-app' | 'gridsome' | 'umijs' | 'sapper' | 'saber' | 'stencil' | 'nuxtjs' | 'redwoodjs' | 'hugo' | 'jekyll' | 'brunch' | 'middleman' | 'zola' | 'hydrogen' | 'vite' | 'tanstack-start' | 'vitepress' | 'vuepress' | 'parcel' | 'fastapi' | 'flask' | 'fasthtml' | 'sanity-v3' | 'sanity' | 'storybook' | 'nitro' | 'hono' | 'express' | 'h3' | 'nestjs' | 'elysia' | 'fastify' | 'xmcp' | null;
|
|
6
|
+
export interface CronJob {
|
|
7
|
+
schedule: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FunctionConfig {
|
|
11
|
+
excludeFiles?: string;
|
|
12
|
+
includeFiles?: string;
|
|
13
|
+
maxDuration?: number;
|
|
14
|
+
memory?: number;
|
|
15
|
+
runtime?: string;
|
|
16
|
+
supportsCancellation?: boolean;
|
|
17
|
+
experimentalTriggers?: Array<{
|
|
18
|
+
type: 'queue/v1beta';
|
|
19
|
+
topic: string;
|
|
20
|
+
consumer: string;
|
|
21
|
+
maxDeliveries?: number;
|
|
22
|
+
retryAfterSeconds?: number;
|
|
23
|
+
initialDelaySeconds?: number;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface GitDeploymentConfig {
|
|
27
|
+
[branch: string]: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface GitConfig {
|
|
30
|
+
deploymentEnabled?: boolean | GitDeploymentConfig;
|
|
31
|
+
}
|
|
32
|
+
export interface GithubConfig {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
autoAlias?: boolean;
|
|
35
|
+
autoJobCancelation?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface Header {
|
|
38
|
+
key: string;
|
|
39
|
+
value: string;
|
|
40
|
+
}
|
|
41
|
+
export interface HeaderRule {
|
|
42
|
+
source: string;
|
|
43
|
+
headers: Header[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Route represents a single routing rule that can be a redirect, rewrite, or header rule
|
|
47
|
+
* Matches the output of router.redirect(), router.rewrite(), router.header(), etc.
|
|
48
|
+
*/
|
|
49
|
+
export type RouteType = any;
|
|
50
|
+
export interface WildcardDomain {
|
|
51
|
+
domain: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}
|
|
54
|
+
export interface VercelConfig {
|
|
55
|
+
/**
|
|
56
|
+
* Aliases that will get assigned when the deployment is `READY` and the target is `production`.
|
|
57
|
+
*/
|
|
58
|
+
alias?: string | string[];
|
|
59
|
+
/**
|
|
60
|
+
* When set to `true`, all HTML files and Serverless Functions will have their extension removed.
|
|
61
|
+
*/
|
|
62
|
+
cleanUrls?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* An array of cron jobs that should be created for production Deployments.
|
|
65
|
+
*/
|
|
66
|
+
crons?: CronJob[];
|
|
67
|
+
/**
|
|
68
|
+
* An object containing the deployment's environment variables.
|
|
69
|
+
*/
|
|
70
|
+
env?: Record<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* An array of the passive regions the deployment's Serverless Functions should be deployed to.
|
|
73
|
+
*/
|
|
74
|
+
passiveRegions?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Same as passiveRegions. An array of passive regions for failover.
|
|
77
|
+
*/
|
|
78
|
+
functionFailoverRegions?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* An object describing custom options for Serverless Functions.
|
|
81
|
+
*/
|
|
82
|
+
functions?: Record<string, FunctionConfig>;
|
|
83
|
+
/**
|
|
84
|
+
* Git-related configuration.
|
|
85
|
+
*/
|
|
86
|
+
git?: GitConfig;
|
|
87
|
+
/**
|
|
88
|
+
* GitHub-related configuration.
|
|
89
|
+
*/
|
|
90
|
+
github?: GithubConfig;
|
|
91
|
+
/**
|
|
92
|
+
* HTTP headers configuration.
|
|
93
|
+
* Can use router.header() and router.cacheControl() helpers.
|
|
94
|
+
*/
|
|
95
|
+
headers?: RouteType[];
|
|
96
|
+
/**
|
|
97
|
+
* HTTP redirects configuration.
|
|
98
|
+
* Can use router.redirect() helper.
|
|
99
|
+
*/
|
|
100
|
+
redirects?: RouteType[];
|
|
101
|
+
/**
|
|
102
|
+
* HTTP rewrites configuration.
|
|
103
|
+
* Can use router.rewrite() helper.
|
|
104
|
+
*/
|
|
105
|
+
rewrites?: RouteType[];
|
|
106
|
+
/**
|
|
107
|
+
* Wildcard domain configuration.
|
|
108
|
+
*/
|
|
109
|
+
wildcard?: WildcardDomain[];
|
|
110
|
+
/**
|
|
111
|
+
* The build command for this project. When `null`, automatically detected.
|
|
112
|
+
*/
|
|
113
|
+
buildCommand?: string | null;
|
|
114
|
+
/**
|
|
115
|
+
* The ignore command for this project.
|
|
116
|
+
*/
|
|
117
|
+
ignoreCommand?: string | null;
|
|
118
|
+
/**
|
|
119
|
+
* The dev command for this project. When `null`, automatically detected.
|
|
120
|
+
*/
|
|
121
|
+
devCommand?: string | null;
|
|
122
|
+
/**
|
|
123
|
+
* The framework being used. When `null`, no framework is selected.
|
|
124
|
+
*/
|
|
125
|
+
framework?: Framework;
|
|
126
|
+
/**
|
|
127
|
+
* The install command for this project. When `null`, automatically detected.
|
|
128
|
+
*/
|
|
129
|
+
installCommand?: string | null;
|
|
130
|
+
/**
|
|
131
|
+
* The output directory of the project. When `null`, automatically detected.
|
|
132
|
+
*/
|
|
133
|
+
outputDirectory?: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* When `false`, visiting a path that ends with a forward slash will redirect to the path without the trailing slash.
|
|
136
|
+
*/
|
|
137
|
+
trailingSlash?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* An array of projectIds to associate with the current project.
|
|
140
|
+
*/
|
|
141
|
+
relatedProjects?: string[];
|
|
142
|
+
/**
|
|
143
|
+
* Enables Fluid compute for the project.
|
|
144
|
+
*/
|
|
145
|
+
fluid?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Enables Bun for the project and specifies the version to use.
|
|
148
|
+
*/
|
|
149
|
+
bunVersion?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Node.js version for this project.
|
|
152
|
+
*/
|
|
153
|
+
nodeVersion?: string;
|
|
154
|
+
}
|
package/dist/types.js
ADDED