vite-plugin-vercel 0.1.6 → 0.2.0
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 +1 -1
- package/dist/index.cjs +14 -5
- package/dist/index.d.ts +77 -78
- package/dist/index.js +10 -3
- package/index.d.ts +1 -1
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Then, install this package as a dev dependency and add it to your Vite config li
|
|
|
29
29
|
```ts
|
|
30
30
|
import { defineConfig } from 'vite';
|
|
31
31
|
import vercel from 'vite-plugin-vercel';
|
|
32
|
-
import ssr from 'vite-plugin-ssr';
|
|
32
|
+
import ssr from 'vite-plugin-ssr/plugin';
|
|
33
33
|
|
|
34
34
|
export default defineConfig({
|
|
35
35
|
plugins: [ssr(), vercel()],
|
package/dist/index.cjs
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -50,7 +54,9 @@ function getPublic(config) {
|
|
|
50
54
|
}
|
|
51
55
|
function pathRelativeTo(filePath, config, rel) {
|
|
52
56
|
const root = getRoot(config);
|
|
53
|
-
return (0, import_vite.normalizePath)(
|
|
57
|
+
return (0, import_vite.normalizePath)(
|
|
58
|
+
import_path.default.relative((0, import_vite.normalizePath)(import_path.default.join(root, rel)), filePath)
|
|
59
|
+
);
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
// src/config.ts
|
|
@@ -155,6 +161,7 @@ function reorderEnforce(arr) {
|
|
|
155
161
|
function getConfig(resolvedConfig, rewrites, overrides) {
|
|
156
162
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
157
163
|
const _rewrites = [
|
|
164
|
+
// User provided config always comes first
|
|
158
165
|
...((_a = resolvedConfig.vercel) == null ? void 0 : _a.rewrites) ?? [],
|
|
159
166
|
...rewrites ?? []
|
|
160
167
|
];
|
|
@@ -250,7 +257,8 @@ function getAdditionalEndpoints(resolvedConfig) {
|
|
|
250
257
|
return (((_a = resolvedConfig.vercel) == null ? void 0 : _a.additionalEndpoints) ?? []).map((e) => ({
|
|
251
258
|
...e,
|
|
252
259
|
addRoute: e.addRoute ?? true,
|
|
253
|
-
|
|
260
|
+
// path.resolve removes the trailing slash if any
|
|
261
|
+
destination: import_path3.default.posix.resolve("/", e.destination) + ".func"
|
|
254
262
|
}));
|
|
255
263
|
}
|
|
256
264
|
function getEntries(resolvedConfig) {
|
|
@@ -267,7 +275,7 @@ function getEntries(resolvedConfig) {
|
|
|
267
275
|
resolvedConfig,
|
|
268
276
|
filePath.includes("/_api/") ? "_api" : "api"
|
|
269
277
|
);
|
|
270
|
-
const parsed = import_path3.default.parse(outFilePath);
|
|
278
|
+
const parsed = import_path3.default.posix.parse(outFilePath);
|
|
271
279
|
entryPoints.push({
|
|
272
280
|
source: filePath,
|
|
273
281
|
destination: `api/${import_path3.default.posix.join(parsed.dir, parsed.name)}.func`,
|
|
@@ -313,6 +321,9 @@ async function buildFn(resolvedConfig, entry, buildOptions) {
|
|
|
313
321
|
options.stdin = entry.source;
|
|
314
322
|
}
|
|
315
323
|
}
|
|
324
|
+
if (entry.edge) {
|
|
325
|
+
options.conditions = ["edge-light", ...options.conditions ?? []];
|
|
326
|
+
}
|
|
316
327
|
await (0, import_esbuild.build)(options);
|
|
317
328
|
await writeVcConfig(resolvedConfig, entry.destination, Boolean(entry.edge));
|
|
318
329
|
}
|
|
@@ -542,5 +553,3 @@ async function getStaticHtmlFiles(src) {
|
|
|
542
553
|
function allPlugins() {
|
|
543
554
|
return [vercelPlugin()];
|
|
544
555
|
}
|
|
545
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
546
|
-
0 && (module.exports = {});
|
package/dist/index.d.ts
CHANGED
|
@@ -32,37 +32,37 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
|
32
32
|
key: z.ZodString;
|
|
33
33
|
value: z.ZodOptional<z.ZodString>;
|
|
34
34
|
}, "strict", z.ZodTypeAny, {
|
|
35
|
-
value?: string | undefined;
|
|
36
35
|
type: "header";
|
|
37
36
|
key: string;
|
|
38
|
-
}, {
|
|
39
37
|
value?: string | undefined;
|
|
38
|
+
}, {
|
|
40
39
|
type: "header";
|
|
41
40
|
key: string;
|
|
41
|
+
value?: string | undefined;
|
|
42
42
|
}>, z.ZodObject<{
|
|
43
43
|
type: z.ZodLiteral<"cookie">;
|
|
44
44
|
key: z.ZodString;
|
|
45
45
|
value: z.ZodOptional<z.ZodString>;
|
|
46
46
|
}, "strict", z.ZodTypeAny, {
|
|
47
|
-
value?: string | undefined;
|
|
48
47
|
type: "cookie";
|
|
49
48
|
key: string;
|
|
50
|
-
}, {
|
|
51
49
|
value?: string | undefined;
|
|
50
|
+
}, {
|
|
52
51
|
type: "cookie";
|
|
53
52
|
key: string;
|
|
53
|
+
value?: string | undefined;
|
|
54
54
|
}>, z.ZodObject<{
|
|
55
55
|
type: z.ZodLiteral<"query">;
|
|
56
56
|
key: z.ZodString;
|
|
57
57
|
value: z.ZodOptional<z.ZodString>;
|
|
58
58
|
}, "strict", z.ZodTypeAny, {
|
|
59
|
-
value?: string | undefined;
|
|
60
59
|
type: "query";
|
|
61
60
|
key: string;
|
|
62
|
-
}, {
|
|
63
61
|
value?: string | undefined;
|
|
62
|
+
}, {
|
|
64
63
|
type: "query";
|
|
65
64
|
key: string;
|
|
65
|
+
value?: string | undefined;
|
|
66
66
|
}>]>, "many">>;
|
|
67
67
|
has: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
68
68
|
type: z.ZodLiteral<"host">;
|
|
@@ -78,154 +78,154 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
|
78
78
|
key: z.ZodString;
|
|
79
79
|
value: z.ZodOptional<z.ZodString>;
|
|
80
80
|
}, "strict", z.ZodTypeAny, {
|
|
81
|
-
value?: string | undefined;
|
|
82
81
|
type: "header";
|
|
83
82
|
key: string;
|
|
84
|
-
}, {
|
|
85
83
|
value?: string | undefined;
|
|
84
|
+
}, {
|
|
86
85
|
type: "header";
|
|
87
86
|
key: string;
|
|
87
|
+
value?: string | undefined;
|
|
88
88
|
}>, z.ZodObject<{
|
|
89
89
|
type: z.ZodLiteral<"cookie">;
|
|
90
90
|
key: z.ZodString;
|
|
91
91
|
value: z.ZodOptional<z.ZodString>;
|
|
92
92
|
}, "strict", z.ZodTypeAny, {
|
|
93
|
-
value?: string | undefined;
|
|
94
93
|
type: "cookie";
|
|
95
94
|
key: string;
|
|
96
|
-
}, {
|
|
97
95
|
value?: string | undefined;
|
|
96
|
+
}, {
|
|
98
97
|
type: "cookie";
|
|
99
98
|
key: string;
|
|
99
|
+
value?: string | undefined;
|
|
100
100
|
}>, z.ZodObject<{
|
|
101
101
|
type: z.ZodLiteral<"query">;
|
|
102
102
|
key: z.ZodString;
|
|
103
103
|
value: z.ZodOptional<z.ZodString>;
|
|
104
104
|
}, "strict", z.ZodTypeAny, {
|
|
105
|
-
value?: string | undefined;
|
|
106
105
|
type: "query";
|
|
107
106
|
key: string;
|
|
108
|
-
}, {
|
|
109
107
|
value?: string | undefined;
|
|
108
|
+
}, {
|
|
110
109
|
type: "query";
|
|
111
110
|
key: string;
|
|
111
|
+
value?: string | undefined;
|
|
112
112
|
}>]>, "many">>;
|
|
113
113
|
locale: z.ZodOptional<z.ZodObject<{
|
|
114
114
|
redirect: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
115
115
|
cookie: z.ZodOptional<z.ZodString>;
|
|
116
116
|
}, "strict", z.ZodTypeAny, {
|
|
117
|
-
cookie?: string | undefined;
|
|
118
117
|
redirect?: Record<string, string> | undefined;
|
|
119
|
-
}, {
|
|
120
118
|
cookie?: string | undefined;
|
|
119
|
+
}, {
|
|
121
120
|
redirect?: Record<string, string> | undefined;
|
|
121
|
+
cookie?: string | undefined;
|
|
122
122
|
}>>;
|
|
123
123
|
middlewarePath: z.ZodOptional<z.ZodString>;
|
|
124
124
|
}, "strict", z.ZodTypeAny, {
|
|
125
|
-
|
|
125
|
+
src: string;
|
|
126
126
|
dest?: string | undefined;
|
|
127
127
|
headers?: Record<string, string> | undefined;
|
|
128
128
|
methods?: string[] | undefined;
|
|
129
|
+
status?: number | undefined;
|
|
129
130
|
continue?: boolean | undefined;
|
|
130
131
|
check?: boolean | undefined;
|
|
131
132
|
missing?: ({
|
|
132
133
|
value: string;
|
|
133
134
|
type: "host";
|
|
134
135
|
} | {
|
|
135
|
-
value?: string | undefined;
|
|
136
136
|
type: "header";
|
|
137
137
|
key: string;
|
|
138
|
-
} | {
|
|
139
138
|
value?: string | undefined;
|
|
139
|
+
} | {
|
|
140
140
|
type: "cookie";
|
|
141
141
|
key: string;
|
|
142
|
-
} | {
|
|
143
142
|
value?: string | undefined;
|
|
143
|
+
} | {
|
|
144
144
|
type: "query";
|
|
145
145
|
key: string;
|
|
146
|
+
value?: string | undefined;
|
|
146
147
|
})[] | undefined;
|
|
147
148
|
has?: ({
|
|
148
149
|
value: string;
|
|
149
150
|
type: "host";
|
|
150
151
|
} | {
|
|
151
|
-
value?: string | undefined;
|
|
152
152
|
type: "header";
|
|
153
153
|
key: string;
|
|
154
|
-
} | {
|
|
155
154
|
value?: string | undefined;
|
|
155
|
+
} | {
|
|
156
156
|
type: "cookie";
|
|
157
157
|
key: string;
|
|
158
|
-
} | {
|
|
159
158
|
value?: string | undefined;
|
|
159
|
+
} | {
|
|
160
160
|
type: "query";
|
|
161
161
|
key: string;
|
|
162
|
+
value?: string | undefined;
|
|
162
163
|
})[] | undefined;
|
|
163
164
|
locale?: {
|
|
164
|
-
cookie?: string | undefined;
|
|
165
165
|
redirect?: Record<string, string> | undefined;
|
|
166
|
+
cookie?: string | undefined;
|
|
166
167
|
} | undefined;
|
|
167
168
|
middlewarePath?: string | undefined;
|
|
168
|
-
src: string;
|
|
169
169
|
}, {
|
|
170
|
-
|
|
170
|
+
src: string;
|
|
171
171
|
dest?: string | undefined;
|
|
172
172
|
headers?: Record<string, string> | undefined;
|
|
173
173
|
methods?: string[] | undefined;
|
|
174
|
+
status?: number | undefined;
|
|
174
175
|
continue?: boolean | undefined;
|
|
175
176
|
check?: boolean | undefined;
|
|
176
177
|
missing?: ({
|
|
177
178
|
value: string;
|
|
178
179
|
type: "host";
|
|
179
180
|
} | {
|
|
180
|
-
value?: string | undefined;
|
|
181
181
|
type: "header";
|
|
182
182
|
key: string;
|
|
183
|
-
} | {
|
|
184
183
|
value?: string | undefined;
|
|
184
|
+
} | {
|
|
185
185
|
type: "cookie";
|
|
186
186
|
key: string;
|
|
187
|
-
} | {
|
|
188
187
|
value?: string | undefined;
|
|
188
|
+
} | {
|
|
189
189
|
type: "query";
|
|
190
190
|
key: string;
|
|
191
|
+
value?: string | undefined;
|
|
191
192
|
})[] | undefined;
|
|
192
193
|
has?: ({
|
|
193
194
|
value: string;
|
|
194
195
|
type: "host";
|
|
195
196
|
} | {
|
|
196
|
-
value?: string | undefined;
|
|
197
197
|
type: "header";
|
|
198
198
|
key: string;
|
|
199
|
-
} | {
|
|
200
199
|
value?: string | undefined;
|
|
200
|
+
} | {
|
|
201
201
|
type: "cookie";
|
|
202
202
|
key: string;
|
|
203
|
-
} | {
|
|
204
203
|
value?: string | undefined;
|
|
204
|
+
} | {
|
|
205
205
|
type: "query";
|
|
206
206
|
key: string;
|
|
207
|
+
value?: string | undefined;
|
|
207
208
|
})[] | undefined;
|
|
208
209
|
locale?: {
|
|
209
|
-
cookie?: string | undefined;
|
|
210
210
|
redirect?: Record<string, string> | undefined;
|
|
211
|
+
cookie?: string | undefined;
|
|
211
212
|
} | undefined;
|
|
212
213
|
middlewarePath?: string | undefined;
|
|
213
|
-
src: string;
|
|
214
214
|
}>, z.ZodObject<{
|
|
215
215
|
handle: z.ZodUnion<[z.ZodLiteral<"rewrite">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"resource">, z.ZodLiteral<"miss">, z.ZodLiteral<"hit">, z.ZodLiteral<"error">]>;
|
|
216
216
|
src: z.ZodOptional<z.ZodString>;
|
|
217
217
|
dest: z.ZodOptional<z.ZodString>;
|
|
218
218
|
status: z.ZodOptional<z.ZodNumber>;
|
|
219
219
|
}, "strict", z.ZodTypeAny, {
|
|
220
|
-
|
|
220
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
221
221
|
src?: string | undefined;
|
|
222
222
|
dest?: string | undefined;
|
|
223
|
-
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
224
|
-
}, {
|
|
225
223
|
status?: number | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
226
226
|
src?: string | undefined;
|
|
227
227
|
dest?: string | undefined;
|
|
228
|
-
|
|
228
|
+
status?: number | undefined;
|
|
229
229
|
}>]>, "many">>;
|
|
230
230
|
images: z.ZodOptional<z.ZodObject<{
|
|
231
231
|
sizes: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
@@ -235,19 +235,19 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
|
235
235
|
dangerouslyAllowSVG: z.ZodOptional<z.ZodBoolean>;
|
|
236
236
|
contentSecurityPolicy: z.ZodOptional<z.ZodString>;
|
|
237
237
|
}, "strict", z.ZodTypeAny, {
|
|
238
|
+
sizes: [number, number];
|
|
238
239
|
domains?: [string, ...string[]] | undefined;
|
|
239
240
|
minimumCacheTTL?: number | undefined;
|
|
240
241
|
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
241
242
|
dangerouslyAllowSVG?: boolean | undefined;
|
|
242
243
|
contentSecurityPolicy?: string | undefined;
|
|
243
|
-
sizes: [number, number];
|
|
244
244
|
}, {
|
|
245
|
+
sizes: [number, number];
|
|
245
246
|
domains?: [string, ...string[]] | undefined;
|
|
246
247
|
minimumCacheTTL?: number | undefined;
|
|
247
248
|
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
248
249
|
dangerouslyAllowSVG?: boolean | undefined;
|
|
249
250
|
contentSecurityPolicy?: string | undefined;
|
|
250
|
-
sizes: [number, number];
|
|
251
251
|
}>>;
|
|
252
252
|
wildcard: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
253
253
|
domain: z.ZodString;
|
|
@@ -271,64 +271,65 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
|
271
271
|
}>>>;
|
|
272
272
|
cache: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
273
273
|
}, "strict", z.ZodTypeAny, {
|
|
274
|
+
version: 3;
|
|
274
275
|
routes?: ({
|
|
275
|
-
|
|
276
|
+
src: string;
|
|
276
277
|
dest?: string | undefined;
|
|
277
278
|
headers?: Record<string, string> | undefined;
|
|
278
279
|
methods?: string[] | undefined;
|
|
280
|
+
status?: number | undefined;
|
|
279
281
|
continue?: boolean | undefined;
|
|
280
282
|
check?: boolean | undefined;
|
|
281
283
|
missing?: ({
|
|
282
284
|
value: string;
|
|
283
285
|
type: "host";
|
|
284
286
|
} | {
|
|
285
|
-
value?: string | undefined;
|
|
286
287
|
type: "header";
|
|
287
288
|
key: string;
|
|
288
|
-
} | {
|
|
289
289
|
value?: string | undefined;
|
|
290
|
+
} | {
|
|
290
291
|
type: "cookie";
|
|
291
292
|
key: string;
|
|
292
|
-
} | {
|
|
293
293
|
value?: string | undefined;
|
|
294
|
+
} | {
|
|
294
295
|
type: "query";
|
|
295
296
|
key: string;
|
|
297
|
+
value?: string | undefined;
|
|
296
298
|
})[] | undefined;
|
|
297
299
|
has?: ({
|
|
298
300
|
value: string;
|
|
299
301
|
type: "host";
|
|
300
302
|
} | {
|
|
301
|
-
value?: string | undefined;
|
|
302
303
|
type: "header";
|
|
303
304
|
key: string;
|
|
304
|
-
} | {
|
|
305
305
|
value?: string | undefined;
|
|
306
|
+
} | {
|
|
306
307
|
type: "cookie";
|
|
307
308
|
key: string;
|
|
308
|
-
} | {
|
|
309
309
|
value?: string | undefined;
|
|
310
|
+
} | {
|
|
310
311
|
type: "query";
|
|
311
312
|
key: string;
|
|
313
|
+
value?: string | undefined;
|
|
312
314
|
})[] | undefined;
|
|
313
315
|
locale?: {
|
|
314
|
-
cookie?: string | undefined;
|
|
315
316
|
redirect?: Record<string, string> | undefined;
|
|
317
|
+
cookie?: string | undefined;
|
|
316
318
|
} | undefined;
|
|
317
319
|
middlewarePath?: string | undefined;
|
|
318
|
-
src: string;
|
|
319
320
|
} | {
|
|
320
|
-
|
|
321
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
321
322
|
src?: string | undefined;
|
|
322
323
|
dest?: string | undefined;
|
|
323
|
-
|
|
324
|
+
status?: number | undefined;
|
|
324
325
|
})[] | undefined;
|
|
325
326
|
images?: {
|
|
327
|
+
sizes: [number, number];
|
|
326
328
|
domains?: [string, ...string[]] | undefined;
|
|
327
329
|
minimumCacheTTL?: number | undefined;
|
|
328
330
|
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
329
331
|
dangerouslyAllowSVG?: boolean | undefined;
|
|
330
332
|
contentSecurityPolicy?: string | undefined;
|
|
331
|
-
sizes: [number, number];
|
|
332
333
|
} | undefined;
|
|
333
334
|
wildcard?: {
|
|
334
335
|
value: string;
|
|
@@ -339,66 +340,66 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
|
339
340
|
contentType?: string | undefined;
|
|
340
341
|
}> | undefined;
|
|
341
342
|
cache?: string[] | undefined;
|
|
342
|
-
version: 3;
|
|
343
343
|
}, {
|
|
344
|
+
version: 3;
|
|
344
345
|
routes?: ({
|
|
345
|
-
|
|
346
|
+
src: string;
|
|
346
347
|
dest?: string | undefined;
|
|
347
348
|
headers?: Record<string, string> | undefined;
|
|
348
349
|
methods?: string[] | undefined;
|
|
350
|
+
status?: number | undefined;
|
|
349
351
|
continue?: boolean | undefined;
|
|
350
352
|
check?: boolean | undefined;
|
|
351
353
|
missing?: ({
|
|
352
354
|
value: string;
|
|
353
355
|
type: "host";
|
|
354
356
|
} | {
|
|
355
|
-
value?: string | undefined;
|
|
356
357
|
type: "header";
|
|
357
358
|
key: string;
|
|
358
|
-
} | {
|
|
359
359
|
value?: string | undefined;
|
|
360
|
+
} | {
|
|
360
361
|
type: "cookie";
|
|
361
362
|
key: string;
|
|
362
|
-
} | {
|
|
363
363
|
value?: string | undefined;
|
|
364
|
+
} | {
|
|
364
365
|
type: "query";
|
|
365
366
|
key: string;
|
|
367
|
+
value?: string | undefined;
|
|
366
368
|
})[] | undefined;
|
|
367
369
|
has?: ({
|
|
368
370
|
value: string;
|
|
369
371
|
type: "host";
|
|
370
372
|
} | {
|
|
371
|
-
value?: string | undefined;
|
|
372
373
|
type: "header";
|
|
373
374
|
key: string;
|
|
374
|
-
} | {
|
|
375
375
|
value?: string | undefined;
|
|
376
|
+
} | {
|
|
376
377
|
type: "cookie";
|
|
377
378
|
key: string;
|
|
378
|
-
} | {
|
|
379
379
|
value?: string | undefined;
|
|
380
|
+
} | {
|
|
380
381
|
type: "query";
|
|
381
382
|
key: string;
|
|
383
|
+
value?: string | undefined;
|
|
382
384
|
})[] | undefined;
|
|
383
385
|
locale?: {
|
|
384
|
-
cookie?: string | undefined;
|
|
385
386
|
redirect?: Record<string, string> | undefined;
|
|
387
|
+
cookie?: string | undefined;
|
|
386
388
|
} | undefined;
|
|
387
389
|
middlewarePath?: string | undefined;
|
|
388
|
-
src: string;
|
|
389
390
|
} | {
|
|
390
|
-
|
|
391
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
391
392
|
src?: string | undefined;
|
|
392
393
|
dest?: string | undefined;
|
|
393
|
-
|
|
394
|
+
status?: number | undefined;
|
|
394
395
|
})[] | undefined;
|
|
395
396
|
images?: {
|
|
397
|
+
sizes: [number, number];
|
|
396
398
|
domains?: [string, ...string[]] | undefined;
|
|
397
399
|
minimumCacheTTL?: number | undefined;
|
|
398
400
|
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
399
401
|
dangerouslyAllowSVG?: boolean | undefined;
|
|
400
402
|
contentSecurityPolicy?: string | undefined;
|
|
401
|
-
sizes: [number, number];
|
|
402
403
|
} | undefined;
|
|
403
404
|
wildcard?: {
|
|
404
405
|
value: string;
|
|
@@ -409,7 +410,6 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
|
409
410
|
contentType?: string | undefined;
|
|
410
411
|
}> | undefined;
|
|
411
412
|
cache?: string[] | undefined;
|
|
412
|
-
version: 3;
|
|
413
413
|
}>;
|
|
414
414
|
type VercelOutputConfig = z.infer<typeof vercelOutputConfigSchema>;
|
|
415
415
|
|
|
@@ -423,13 +423,13 @@ declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
423
423
|
entrypoint: z.ZodString;
|
|
424
424
|
envVarsInUse: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
425
425
|
}, "strict", z.ZodTypeAny, {
|
|
426
|
-
envVarsInUse?: string[] | undefined;
|
|
427
426
|
runtime: "edge";
|
|
428
427
|
entrypoint: string;
|
|
429
|
-
}, {
|
|
430
428
|
envVarsInUse?: string[] | undefined;
|
|
429
|
+
}, {
|
|
431
430
|
runtime: "edge";
|
|
432
431
|
entrypoint: string;
|
|
432
|
+
envVarsInUse?: string[] | undefined;
|
|
433
433
|
}>, z.ZodObject<{
|
|
434
434
|
runtime: z.ZodString;
|
|
435
435
|
handler: z.ZodString;
|
|
@@ -438,32 +438,34 @@ declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
438
438
|
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
439
439
|
regions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
440
440
|
}, "strict", z.ZodTypeAny, {
|
|
441
|
+
runtime: string;
|
|
442
|
+
handler: string;
|
|
441
443
|
memory?: number | undefined;
|
|
442
444
|
maxDuration?: number | undefined;
|
|
443
445
|
environment?: Record<string, string> | undefined;
|
|
444
446
|
regions?: string[] | undefined;
|
|
447
|
+
}, {
|
|
445
448
|
runtime: string;
|
|
446
449
|
handler: string;
|
|
447
|
-
}, {
|
|
448
450
|
memory?: number | undefined;
|
|
449
451
|
maxDuration?: number | undefined;
|
|
450
452
|
environment?: Record<string, string> | undefined;
|
|
451
453
|
regions?: string[] | undefined;
|
|
452
|
-
|
|
453
|
-
handler: string;
|
|
454
|
-
}>, z.ZodObject<z.extendShape<{
|
|
454
|
+
}>, z.ZodObject<{
|
|
455
455
|
runtime: z.ZodString;
|
|
456
456
|
handler: z.ZodString;
|
|
457
457
|
memory: z.ZodOptional<z.ZodNumber>;
|
|
458
458
|
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
459
459
|
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
460
460
|
regions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
461
|
-
}, {
|
|
462
461
|
launcherType: z.ZodLiteral<"Nodejs">;
|
|
463
462
|
shouldAddHelpers: z.ZodOptional<z.ZodBoolean>;
|
|
464
463
|
shouldAddSourcemapSupport: z.ZodOptional<z.ZodBoolean>;
|
|
465
464
|
awsLambdaHandler: z.ZodOptional<z.ZodString>;
|
|
466
|
-
}
|
|
465
|
+
}, "strict", z.ZodTypeAny, {
|
|
466
|
+
runtime: string;
|
|
467
|
+
handler: string;
|
|
468
|
+
launcherType: "Nodejs";
|
|
467
469
|
memory?: number | undefined;
|
|
468
470
|
maxDuration?: number | undefined;
|
|
469
471
|
environment?: Record<string, string> | undefined;
|
|
@@ -471,10 +473,10 @@ declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
471
473
|
shouldAddHelpers?: boolean | undefined;
|
|
472
474
|
shouldAddSourcemapSupport?: boolean | undefined;
|
|
473
475
|
awsLambdaHandler?: string | undefined;
|
|
476
|
+
}, {
|
|
474
477
|
runtime: string;
|
|
475
478
|
handler: string;
|
|
476
479
|
launcherType: "Nodejs";
|
|
477
|
-
}, {
|
|
478
480
|
memory?: number | undefined;
|
|
479
481
|
maxDuration?: number | undefined;
|
|
480
482
|
environment?: Record<string, string> | undefined;
|
|
@@ -482,9 +484,6 @@ declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
482
484
|
shouldAddHelpers?: boolean | undefined;
|
|
483
485
|
shouldAddSourcemapSupport?: boolean | undefined;
|
|
484
486
|
awsLambdaHandler?: string | undefined;
|
|
485
|
-
runtime: string;
|
|
486
|
-
handler: string;
|
|
487
|
-
launcherType: "Nodejs";
|
|
488
487
|
}>]>;
|
|
489
488
|
type VercelOutputVcConfig = z.infer<typeof vercelOutputVcConfigSchema>;
|
|
490
489
|
|
|
@@ -500,17 +499,17 @@ declare const vercelOutputPrerenderConfigSchema: z.ZodObject<{
|
|
|
500
499
|
fallback: z.ZodOptional<z.ZodString>;
|
|
501
500
|
allowQuery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
502
501
|
}, "strict", z.ZodTypeAny, {
|
|
502
|
+
expiration: number | false;
|
|
503
503
|
group?: number | undefined;
|
|
504
504
|
bypassToken?: string | undefined;
|
|
505
505
|
fallback?: string | undefined;
|
|
506
506
|
allowQuery?: string[] | undefined;
|
|
507
|
-
expiration: number | false;
|
|
508
507
|
}, {
|
|
508
|
+
expiration: number | false;
|
|
509
509
|
group?: number | undefined;
|
|
510
510
|
bypassToken?: string | undefined;
|
|
511
511
|
fallback?: string | undefined;
|
|
512
512
|
allowQuery?: string[] | undefined;
|
|
513
|
-
expiration: number | false;
|
|
514
513
|
}>;
|
|
515
514
|
type VercelOutputPrerenderConfig = z.infer<typeof vercelOutputPrerenderConfigSchema>;
|
|
516
515
|
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,9 @@ function getPublic(config) {
|
|
|
20
20
|
}
|
|
21
21
|
function pathRelativeTo(filePath, config, rel) {
|
|
22
22
|
const root = getRoot(config);
|
|
23
|
-
return normalizePath(
|
|
23
|
+
return normalizePath(
|
|
24
|
+
path.relative(normalizePath(path.join(root, rel)), filePath)
|
|
25
|
+
);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
// src/config.ts
|
|
@@ -125,6 +127,7 @@ function reorderEnforce(arr) {
|
|
|
125
127
|
function getConfig(resolvedConfig, rewrites, overrides) {
|
|
126
128
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
127
129
|
const _rewrites = [
|
|
130
|
+
// User provided config always comes first
|
|
128
131
|
...((_a = resolvedConfig.vercel) == null ? void 0 : _a.rewrites) ?? [],
|
|
129
132
|
...rewrites ?? []
|
|
130
133
|
];
|
|
@@ -220,7 +223,8 @@ function getAdditionalEndpoints(resolvedConfig) {
|
|
|
220
223
|
return (((_a = resolvedConfig.vercel) == null ? void 0 : _a.additionalEndpoints) ?? []).map((e) => ({
|
|
221
224
|
...e,
|
|
222
225
|
addRoute: e.addRoute ?? true,
|
|
223
|
-
|
|
226
|
+
// path.resolve removes the trailing slash if any
|
|
227
|
+
destination: path3.posix.resolve("/", e.destination) + ".func"
|
|
224
228
|
}));
|
|
225
229
|
}
|
|
226
230
|
function getEntries(resolvedConfig) {
|
|
@@ -237,7 +241,7 @@ function getEntries(resolvedConfig) {
|
|
|
237
241
|
resolvedConfig,
|
|
238
242
|
filePath.includes("/_api/") ? "_api" : "api"
|
|
239
243
|
);
|
|
240
|
-
const parsed = path3.parse(outFilePath);
|
|
244
|
+
const parsed = path3.posix.parse(outFilePath);
|
|
241
245
|
entryPoints.push({
|
|
242
246
|
source: filePath,
|
|
243
247
|
destination: `api/${path3.posix.join(parsed.dir, parsed.name)}.func`,
|
|
@@ -283,6 +287,9 @@ async function buildFn(resolvedConfig, entry, buildOptions) {
|
|
|
283
287
|
options.stdin = entry.source;
|
|
284
288
|
}
|
|
285
289
|
}
|
|
290
|
+
if (entry.edge) {
|
|
291
|
+
options.conditions = ["edge-light", ...options.conditions ?? []];
|
|
292
|
+
}
|
|
286
293
|
await build(options);
|
|
287
294
|
await writeVcConfig(resolvedConfig, entry.destination, Boolean(entry.edge));
|
|
288
295
|
}
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-vercel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"module": "./dist/index.js",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
13
14
|
"import": "./dist/index.js",
|
|
14
15
|
"require": "./dist/index.cjs"
|
|
15
16
|
}
|
|
@@ -20,23 +21,23 @@
|
|
|
20
21
|
"repository": "https://github.com/magne4000/vite-plugin-vercel",
|
|
21
22
|
"license": "MIT",
|
|
22
23
|
"peerDependencies": {
|
|
23
|
-
"vite": "^
|
|
24
|
+
"vite": "^4.2.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@types/node": "^16.18.
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
28
|
-
"@typescript-eslint/parser": "^5.
|
|
29
|
-
"eslint": "^8.
|
|
30
|
-
"tsup": "^6.
|
|
31
|
-
"typescript": "^
|
|
32
|
-
"vite": "^3.
|
|
27
|
+
"@types/node": "^16.18.30",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
29
|
+
"@typescript-eslint/parser": "^5.59.5",
|
|
30
|
+
"eslint": "^8.40.0",
|
|
31
|
+
"tsup": "^6.7.0",
|
|
32
|
+
"typescript": "^5.0.4",
|
|
33
|
+
"vite": "^4.3.5"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@brillout/libassert": "^0.5.8",
|
|
36
|
-
"@vercel/routing-utils": "^2.1
|
|
37
|
-
"esbuild": "^0.
|
|
37
|
+
"@vercel/routing-utils": "^2.2.1",
|
|
38
|
+
"esbuild": "^0.17.19",
|
|
38
39
|
"fast-glob": "^3.2.12",
|
|
39
|
-
"zod": "^3.
|
|
40
|
+
"zod": "^3.21.4"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
42
43
|
"build": "tsup",
|