vite-plugin-vercel 0.0.1 → 0.0.2

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/dist/index.d.ts CHANGED
@@ -1,5 +1,213 @@
1
- import { Plugin } from 'vite';
1
+ import { ResolvedConfig, Plugin } from 'vite';
2
+ import { StdinOptions, BuildOptions } from 'esbuild';
3
+ import * as myzod_libs_types from 'myzod/libs/types';
4
+ import * as myzod from 'myzod';
5
+
6
+ declare const routesManifestDynamicRouteSchema: myzod.ObjectType<{
7
+ page: myzod.StringType;
8
+ regex: myzod.StringType;
9
+ routeKeys: myzod.OptionalType<myzod.ObjectType<{
10
+ [myzod.keySignature]: myzod.AnyType;
11
+ }>>;
12
+ namedRegex: myzod.OptionalType<myzod.StringType>;
13
+ }>;
14
+ declare const routesManifestSchema: myzod.ObjectType<{
15
+ version: myzod_libs_types.LiteralType<3>;
16
+ basePath: myzod.StringType;
17
+ pages404: myzod.BooleanType;
18
+ redirects: myzod.OptionalType<myzod.ArrayType<myzod.ObjectType<{
19
+ source: myzod.StringType;
20
+ destination: myzod.StringType;
21
+ statusCode: myzod.UnionType<[myzod_libs_types.LiteralType<301>, myzod_libs_types.LiteralType<302>, myzod_libs_types.LiteralType<307>, myzod_libs_types.LiteralType<308>]>;
22
+ regex: myzod.StringType;
23
+ }>>>;
24
+ headers: myzod.OptionalType<myzod.ArrayType<myzod.ObjectType<{
25
+ source: myzod.StringType;
26
+ headers: myzod.ArrayType<myzod.ObjectType<{
27
+ key: myzod.StringType;
28
+ value: myzod.StringType;
29
+ }>>;
30
+ regex: myzod.StringType;
31
+ }>>>;
32
+ rewrites: myzod.OptionalType<myzod.ArrayType<myzod.ObjectType<{
33
+ source: myzod.StringType;
34
+ has: myzod.OptionalType<myzod.ArrayType<myzod.ObjectType<{
35
+ key: myzod.StringType;
36
+ value: myzod.StringType;
37
+ type: myzod.UnionType<[myzod_libs_types.LiteralType<"header">, myzod_libs_types.LiteralType<"cookie">, myzod_libs_types.LiteralType<"host">, myzod_libs_types.LiteralType<"query">]>;
38
+ }>>>;
39
+ destination: myzod.StringType;
40
+ regex: myzod.StringType;
41
+ }>>>;
42
+ dynamicRoutes: myzod.OptionalType<myzod.ArrayType<myzod.ObjectType<{
43
+ page: myzod.StringType;
44
+ regex: myzod.StringType;
45
+ routeKeys: myzod.OptionalType<myzod.ObjectType<{
46
+ [myzod.keySignature]: myzod.AnyType;
47
+ }>>;
48
+ namedRegex: myzod.OptionalType<myzod.StringType>;
49
+ }>>>;
50
+ }>;
51
+ declare type RoutesManifest = myzod.Infer<typeof routesManifestSchema>;
52
+ declare type RoutesManifestDynamicRoute = myzod.Infer<typeof routesManifestDynamicRouteSchema>;
53
+ declare type RoutesManifestDefault = Partial<Omit<RoutesManifest, 'version'>>;
54
+
55
+ declare const functionsManifestSchema: myzod.ObjectType<{
56
+ version: myzod_libs_types.LiteralType<1>;
57
+ pages: myzod.ObjectType<{
58
+ '_middleware.js': myzod.OptionalType<myzod.ObjectType<{
59
+ handler: myzod.OptionalType<myzod.StringType>;
60
+ regions: myzod.OptionalType<myzod.ArrayType<myzod.StringType>>;
61
+ maxDuration: myzod.OptionalType<myzod.NumberType>;
62
+ memory: myzod.OptionalType<myzod.NumberType>;
63
+ runtime: myzod_libs_types.LiteralType<"web">;
64
+ env: myzod.ArrayType<myzod.StringType>;
65
+ files: myzod.ArrayType<myzod.StringType>;
66
+ name: myzod.StringType;
67
+ page: myzod.StringType;
68
+ regexp: myzod.StringType;
69
+ sortingIndex: myzod.NumberType;
70
+ }>>;
71
+ [myzod.keySignature]: myzod.AnyType;
72
+ }>;
73
+ }>;
74
+ declare type FunctionsManifest = myzod.Infer<typeof functionsManifestSchema>;
75
+
76
+ declare const prerenderManifestSchemaRoute: myzod.ObjectType<{
77
+ initialRevalidateSeconds: myzod.NumberType;
78
+ srcRoute: myzod.StringType;
79
+ dataRoute: myzod.StringType;
80
+ }>;
81
+ declare const prerenderManifestSchemaDynamicRoute: myzod.ObjectType<{
82
+ routeRegex: myzod.StringType;
83
+ fallback: myzod.UnionType<[myzod.StringType, myzod.NullType]>;
84
+ dataRoute: myzod.StringType;
85
+ dataRouteRegex: myzod.StringType;
86
+ }>;
87
+ declare const prerenderManifestSchema: myzod.ObjectType<{
88
+ version: myzod_libs_types.LiteralType<3>;
89
+ routes: myzod.ObjectType<{
90
+ [myzod.keySignature]: myzod.ObjectType<{
91
+ initialRevalidateSeconds: myzod.NumberType;
92
+ srcRoute: myzod.StringType;
93
+ dataRoute: myzod.StringType;
94
+ }>;
95
+ }>;
96
+ dynamicRoutes: myzod.ObjectType<{
97
+ [myzod.keySignature]: myzod.ObjectType<{
98
+ routeRegex: myzod.StringType;
99
+ fallback: myzod.UnionType<[myzod.StringType, myzod.NullType]>;
100
+ dataRoute: myzod.StringType;
101
+ dataRouteRegex: myzod.StringType;
102
+ }>;
103
+ }>;
104
+ preview: myzod.ObjectType<{
105
+ previewModeId: myzod.UnionType<[myzod.StringType, myzod.NullType]>;
106
+ }>;
107
+ }>;
108
+ declare type PrerenderManifest = myzod.Infer<typeof prerenderManifestSchema>;
109
+ declare type PrerenderManifestRoute = myzod.Infer<typeof prerenderManifestSchemaRoute>;
110
+ declare type PrerenderManifestDynamicRoute = myzod.Infer<typeof prerenderManifestSchemaDynamicRoute>;
111
+ declare type DeepPartial<T> = T extends Function ? T : T extends object ? {
112
+ [P in keyof T]?: DeepPartial<T[P]>;
113
+ } : T;
114
+ declare type PrerenderManifestDefault = DeepPartial<PrerenderManifest>;
115
+
116
+ interface ViteVercelConfig {
117
+ /**
118
+ * How long Functions should be allowed to run for every request in seconds.
119
+ * If left empty, default value for your plan will is used.
120
+ */
121
+ defaultMaxDuration?: number;
122
+ /**
123
+ * If ISR is supported, default revalidation time per-page can be overriden.
124
+ * A `prerender` function is necessary for ISR to work.
125
+ * Defaults to 86400 seconds (24h).
126
+ * @see {@link https://vercel.com/docs/concepts/next.js/incremental-static-regeneration}
127
+ */
128
+ initialRevalidateSeconds?: number;
129
+ /**
130
+ * Also known as Server Side Generation, or SSG.
131
+ * If present, must build static files in `.output/server/pages`.
132
+ * Can be set to `false` to disable prerendering completely.
133
+ */
134
+ prerender?: ViteVercelPrerenderFn | false;
135
+ /**
136
+ * By default, all `api/*` endpoints are compiled under `.ouput/server/pages/api`.
137
+ * If a file must also be compiled only under `.ouput/server/pages`, it should be added here.
138
+ *
139
+ * @example
140
+ * ```
141
+ * {
142
+ * pagesEndpoints: ['./api/page.ts']
143
+ * }
144
+ * ```
145
+ */
146
+ pagesEndpoints?: string[];
147
+ /**
148
+ * All provided endpoints will also be part of the build process.
149
+ * For instance, a framework can leverage this to have a generic ssr endpoint
150
+ * without requiring the user to write any code.
151
+ *
152
+ * @example
153
+ * ```
154
+ * {
155
+ * additionalEndpoints: [
156
+ * {
157
+ * // can also be an Object representing an esbuild StdinOptions
158
+ * source: '/path/to/file.ts',
159
+ * // relative to `.output/server/pages`, without extension
160
+ * destination: ['file', '/api/file'],
161
+ * }
162
+ * ]
163
+ * }
164
+ * ```
165
+ */
166
+ additionalEndpoints?: ViteVercelApiEntry[];
167
+ /**
168
+ * Advanced configuration to override funtions-manifest.json
169
+ * @see {@link https://vercel.com/docs/file-system-api#configuration/functions}
170
+ * @protected
171
+ */
172
+ functionsManifest?: Partial<Omit<FunctionsManifest, 'version'>>;
173
+ /**
174
+ * Advanced configuration to override routes-manifest.json
175
+ * @see {@link https://vercel.com/docs/file-system-api#configuration/routes}
176
+ * @protected
177
+ */
178
+ routesManifest?: RoutesManifestDefault;
179
+ /**
180
+ * Advanced configuration to override prerender-manifest.json
181
+ * @see {@link https://vercel.com/docs/file-system-api#configuration/pre-rendering}
182
+ * @protected
183
+ */
184
+ prerenderManifest?: PrerenderManifestDefault;
185
+ /**
186
+ * Defaults to `.output`. Mostly useful for testing prupose
187
+ * @protected
188
+ */
189
+ outDir?: string;
190
+ }
191
+ declare type ViteVercelPrerenderRoute = {
192
+ isr?: Pick<PrerenderManifestDefault, 'routes'>;
193
+ ssr?: Pick<RoutesManifestDefault, 'rewrites' | 'dynamicRoutes'>;
194
+ };
195
+ declare type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => ViteVercelPrerenderRoute | Promise<ViteVercelPrerenderRoute>;
196
+ interface ViteVercelApiEntry {
197
+ /**
198
+ * Path to entry file, or stdin config
199
+ */
200
+ source: string | StdinOptions;
201
+ /**
202
+ * Relative to `.output/server/pages`, without extension
203
+ */
204
+ destination: string | string[];
205
+ /**
206
+ * Override esbuild options
207
+ */
208
+ buildOptions?: BuildOptions;
209
+ }
2
210
 
3
211
  declare function allPlugins(): Plugin[];
4
212
 
5
- export { allPlugins as default };
213
+ export { FunctionsManifest, PrerenderManifest, PrerenderManifestDefault, PrerenderManifestDynamicRoute, PrerenderManifestRoute, RoutesManifest, RoutesManifestDefault, RoutesManifestDynamicRoute, ViteVercelApiEntry, ViteVercelConfig, ViteVercelPrerenderFn, ViteVercelPrerenderRoute, allPlugins as default };
package/dist/index.js CHANGED
@@ -93,106 +93,106 @@ function assert(condition, errorMessage) {
93
93
  }
94
94
 
95
95
  // src/schemas/manifests/routes.ts
96
- var import_myzod = __toESM(require("myzod"));
96
+ var myzod = __toESM(require("myzod"));
97
97
  function record(schema) {
98
- return import_myzod.default.object({
99
- [import_myzod.default.keySignature]: schema
98
+ return myzod.object({
99
+ [myzod.keySignature]: schema
100
100
  });
101
101
  }
102
- var routesManifestRedirectSchema = import_myzod.default.object({
103
- source: import_myzod.default.string(),
104
- destination: import_myzod.default.string(),
105
- statusCode: import_myzod.default.literals(301, 302, 307, 308),
106
- regex: import_myzod.default.string()
102
+ var routesManifestRedirectSchema = myzod.object({
103
+ source: myzod.string(),
104
+ destination: myzod.string(),
105
+ statusCode: myzod.literals(301, 302, 307, 308),
106
+ regex: myzod.string()
107
107
  });
108
- var routesManifestHeaderSchema = import_myzod.default.object({
109
- source: import_myzod.default.string(),
110
- headers: import_myzod.default.array(import_myzod.default.object({
111
- key: import_myzod.default.string(),
112
- value: import_myzod.default.string()
108
+ var routesManifestHeaderSchema = myzod.object({
109
+ source: myzod.string(),
110
+ headers: myzod.array(myzod.object({
111
+ key: myzod.string(),
112
+ value: myzod.string()
113
113
  })),
114
- regex: import_myzod.default.string()
114
+ regex: myzod.string()
115
115
  });
116
- var routesManifestRewriteSchema = import_myzod.default.object({
117
- source: import_myzod.default.string(),
118
- has: import_myzod.default.array(import_myzod.default.object({
119
- key: import_myzod.default.string(),
120
- value: import_myzod.default.string(),
121
- type: import_myzod.default.literals("header", "cookie", "host", "query")
116
+ var routesManifestRewriteSchema = myzod.object({
117
+ source: myzod.string(),
118
+ has: myzod.array(myzod.object({
119
+ key: myzod.string(),
120
+ value: myzod.string(),
121
+ type: myzod.literals("header", "cookie", "host", "query")
122
122
  })).optional(),
123
- destination: import_myzod.default.string(),
124
- regex: import_myzod.default.string()
123
+ destination: myzod.string(),
124
+ regex: myzod.string()
125
125
  });
126
- var routesManifestDynamicRouteSchema = import_myzod.default.object({
127
- page: import_myzod.default.string(),
128
- regex: import_myzod.default.string(),
129
- routeKeys: record(import_myzod.default.string()).optional(),
130
- namedRegex: import_myzod.default.string().optional()
126
+ var routesManifestDynamicRouteSchema = myzod.object({
127
+ page: myzod.string(),
128
+ regex: myzod.string(),
129
+ routeKeys: record(myzod.string()).optional(),
130
+ namedRegex: myzod.string().optional()
131
131
  });
132
- var routesManifestSchema = import_myzod.default.object({
133
- version: import_myzod.default.literal(3),
134
- basePath: import_myzod.default.string().pattern(/^\/.*/),
135
- pages404: import_myzod.default.boolean(),
136
- redirects: import_myzod.default.array(routesManifestRedirectSchema).optional(),
137
- headers: import_myzod.default.array(routesManifestHeaderSchema).optional(),
138
- rewrites: import_myzod.default.array(routesManifestRewriteSchema).optional(),
139
- dynamicRoutes: import_myzod.default.array(routesManifestDynamicRouteSchema).optional()
132
+ var routesManifestSchema = myzod.object({
133
+ version: myzod.literal(3),
134
+ basePath: myzod.string().pattern(/^\/.*/),
135
+ pages404: myzod.boolean(),
136
+ redirects: myzod.array(routesManifestRedirectSchema).optional(),
137
+ headers: myzod.array(routesManifestHeaderSchema).optional(),
138
+ rewrites: myzod.array(routesManifestRewriteSchema).optional(),
139
+ dynamicRoutes: myzod.array(routesManifestDynamicRouteSchema).optional()
140
140
  });
141
141
 
142
142
  // src/schemas/manifests/functions.ts
143
- var import_myzod2 = __toESM(require("myzod"));
143
+ var myzod2 = __toESM(require("myzod"));
144
144
  function record2(schema) {
145
- return import_myzod2.default.object({
146
- [import_myzod2.default.keySignature]: schema
145
+ return myzod2.object({
146
+ [myzod2.keySignature]: schema
147
147
  });
148
148
  }
149
- var functionsManifestSchemaPage = import_myzod2.default.object({
150
- runtime: import_myzod2.default.string().optional(),
151
- handler: import_myzod2.default.string().optional(),
152
- regions: import_myzod2.default.array(import_myzod2.default.string()).optional(),
153
- maxDuration: import_myzod2.default.number().min(1).max(900).optional(),
154
- memory: import_myzod2.default.number().min(128).max(3008).optional()
149
+ var functionsManifestSchemaPage = myzod2.object({
150
+ runtime: myzod2.string().optional(),
151
+ handler: myzod2.string().optional(),
152
+ regions: myzod2.array(myzod2.string()).optional(),
153
+ maxDuration: myzod2.number().min(1).max(900).optional(),
154
+ memory: myzod2.number().min(128).max(3008).optional()
155
155
  });
156
- var functionsManifestSchemaPageWeb = import_myzod2.default.omit(functionsManifestSchemaPage, ["runtime"]).and(import_myzod2.default.object({
157
- runtime: import_myzod2.default.literal("web"),
158
- env: import_myzod2.default.array(import_myzod2.default.string()),
159
- files: import_myzod2.default.array(import_myzod2.default.string()),
160
- name: import_myzod2.default.string(),
161
- page: import_myzod2.default.string(),
162
- regexp: import_myzod2.default.string(),
163
- sortingIndex: import_myzod2.default.number()
156
+ var functionsManifestSchemaPageWeb = myzod2.omit(functionsManifestSchemaPage, ["runtime"]).and(myzod2.object({
157
+ runtime: myzod2.literal("web"),
158
+ env: myzod2.array(myzod2.string()),
159
+ files: myzod2.array(myzod2.string()),
160
+ name: myzod2.string(),
161
+ page: myzod2.string(),
162
+ regexp: myzod2.string(),
163
+ sortingIndex: myzod2.number()
164
164
  }));
165
- var functionsManifestSchema = import_myzod2.default.object({
166
- version: import_myzod2.default.literal(1),
167
- pages: import_myzod2.default.object({
165
+ var functionsManifestSchema = myzod2.object({
166
+ version: myzod2.literal(1),
167
+ pages: myzod2.object({
168
168
  "_middleware.js": functionsManifestSchemaPageWeb.optional()
169
- }).and(record2(import_myzod2.default.intersection(import_myzod2.default.partial(import_myzod2.default.omit(functionsManifestSchemaPageWeb, ["runtime"])), functionsManifestSchemaPage)))
169
+ }).and(record2(myzod2.intersection(myzod2.partial(myzod2.omit(functionsManifestSchemaPageWeb, ["runtime"])), functionsManifestSchemaPage)))
170
170
  });
171
171
 
172
172
  // src/schemas/manifests/prerender.ts
173
- var import_myzod3 = __toESM(require("myzod"));
173
+ var myzod3 = __toESM(require("myzod"));
174
174
  function record3(schema) {
175
- return import_myzod3.default.object({
176
- [import_myzod3.default.keySignature]: schema
175
+ return myzod3.object({
176
+ [myzod3.keySignature]: schema
177
177
  });
178
178
  }
179
- var prerenderManifestSchemaRoute = import_myzod3.default.object({
180
- initialRevalidateSeconds: import_myzod3.default.number(),
181
- srcRoute: import_myzod3.default.string(),
182
- dataRoute: import_myzod3.default.string()
179
+ var prerenderManifestSchemaRoute = myzod3.object({
180
+ initialRevalidateSeconds: myzod3.number(),
181
+ srcRoute: myzod3.string(),
182
+ dataRoute: myzod3.string()
183
183
  });
184
- var prerenderManifestSchemaDynamicRoute = import_myzod3.default.object({
185
- routeRegex: import_myzod3.default.string(),
186
- fallback: import_myzod3.default.string().or(import_myzod3.default.null()),
187
- dataRoute: import_myzod3.default.string(),
188
- dataRouteRegex: import_myzod3.default.string()
184
+ var prerenderManifestSchemaDynamicRoute = myzod3.object({
185
+ routeRegex: myzod3.string(),
186
+ fallback: myzod3.string().or(myzod3.null()),
187
+ dataRoute: myzod3.string(),
188
+ dataRouteRegex: myzod3.string()
189
189
  });
190
- var prerenderManifestSchema = import_myzod3.default.object({
191
- version: import_myzod3.default.literal(3),
190
+ var prerenderManifestSchema = myzod3.object({
191
+ version: myzod3.literal(3),
192
192
  routes: record3(prerenderManifestSchemaRoute),
193
193
  dynamicRoutes: record3(prerenderManifestSchemaDynamicRoute),
194
- preview: import_myzod3.default.object({
195
- previewModeId: import_myzod3.default.string().or(import_myzod3.default.null())
194
+ preview: myzod3.object({
195
+ previewModeId: myzod3.string().or(myzod3.null())
196
196
  })
197
197
  });
198
198
 
package/dist/index.mjs CHANGED
@@ -64,7 +64,7 @@ function assert(condition, errorMessage) {
64
64
  }
65
65
 
66
66
  // src/schemas/manifests/routes.ts
67
- import myzod from "myzod";
67
+ import * as myzod from "myzod";
68
68
  function record(schema) {
69
69
  return myzod.object({
70
70
  [myzod.keySignature]: schema
@@ -111,7 +111,7 @@ var routesManifestSchema = myzod.object({
111
111
  });
112
112
 
113
113
  // src/schemas/manifests/functions.ts
114
- import myzod2 from "myzod";
114
+ import * as myzod2 from "myzod";
115
115
  function record2(schema) {
116
116
  return myzod2.object({
117
117
  [myzod2.keySignature]: schema
@@ -141,7 +141,7 @@ var functionsManifestSchema = myzod2.object({
141
141
  });
142
142
 
143
143
  // src/schemas/manifests/prerender.ts
144
- import myzod3 from "myzod";
144
+ import * as myzod3 from "myzod";
145
145
  function record3(schema) {
146
146
  return myzod3.object({
147
147
  [myzod3.keySignature]: schema
package/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { ViteVercelConfig } from './src/types';
1
+ import { ViteVercelConfig } from './dist';
2
2
 
3
3
  export * from './dist';
4
- export * from './src/types';
5
4
  export { default } from './dist';
6
5
 
7
6
  declare module 'vite' {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vercel",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "module": "./dist/index.mjs",
5
5
  "files": [
6
6
  "dist",