vite-plugin-vercel 10.0.0 → 11.0.0-beta.3

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.
@@ -0,0 +1,10 @@
1
+ import path from "node:path";
2
+ import { normalizePath } from "vite";
3
+
4
+ //#region src/utils/path.ts
5
+ function pathRelativeTo(filePath, rel) {
6
+ return normalizePath(path.relative(normalizePath(path.resolve(rel)), path.resolve(filePath)));
7
+ }
8
+
9
+ //#endregion
10
+ export { pathRelativeTo as t };
@@ -0,0 +1,108 @@
1
+ import { VercelOutputConfig, VercelOutputPrerenderConfig } from "@vite-plugin-vercel/schemas";
2
+ import { Plugin } from "vite";
3
+ import { EntryMeta } from "@universal-deploy/store";
4
+ import { Header, Redirect, Rewrite } from "@vercel/routing-utils";
5
+
6
+ //#region src/types.d.ts
7
+ type ViteVercelRewrite = Rewrite & {
8
+ enforce?: "pre" | "post";
9
+ };
10
+ type ViteVercelRedirect = Redirect & {
11
+ enforce?: "pre" | "post";
12
+ };
13
+ type PluginContext = ThisParameterType<Extract<Plugin["resolveId"], (...args: never) => any>>;
14
+ interface ViteVercelConfig {
15
+ /**
16
+ * @experimental
17
+ * @default basic
18
+ */
19
+ bundleStrategy?: "basic" | "nf3";
20
+ /**
21
+ * How long Functions should be allowed to run for every request, in seconds.
22
+ * If left empty, default value for your plan will be used.
23
+ */
24
+ defaultMaxDuration?: number;
25
+ /**
26
+ * Default expiration time (in seconds) for prerender functions.
27
+ * Defaults to 86400 seconds (24h).
28
+ * @see {@link https://vercel.com/docs/concepts/next.js/incremental-static-regeneration}
29
+ * @see {@link https://vercel.com/docs/build-output-api/v3#vercel-primitives/prerender-functions/configuration}
30
+ */
31
+ expiration?: number;
32
+ /**
33
+ * @see {@link https://vercel.com/docs/projects/project-configuration#rewrites}
34
+ */
35
+ rewrites?: ViteVercelRewrite[];
36
+ /**
37
+ * @see {@link https://vercel.com/docs/projects/project-configuration#headers}
38
+ * @beta
39
+ */
40
+ headers?: Header[];
41
+ /**
42
+ * @see {@link https://vercel.com/docs/projects/project-configuration#redirects}
43
+ */
44
+ redirects?: ViteVercelRedirect[];
45
+ /**
46
+ * @see {@link https://vercel.com/docs/projects/project-configuration#cleanurls}
47
+ */
48
+ cleanUrls?: boolean;
49
+ /**
50
+ * @see {@link https://vercel.com/docs/projects/project-configuration#trailingslash}
51
+ */
52
+ trailingSlash?: boolean;
53
+ /**
54
+ * When true, the Serverless Function will stream the response to the client.
55
+ * @see {@link https://vercel.com/docs/build-output-api/v3/primitives#serverless-function-configuration}
56
+ * @default true
57
+ */
58
+ defaultSupportsResponseStreaming?: boolean;
59
+ /**
60
+ * Use `getVercelEntries` for mapping your filesystem routes to entries.
61
+ */
62
+ entries?: EntryMeta[];
63
+ /**
64
+ * Advanced configuration to override .vercel/output/config.json
65
+ * @see {@link https://vercel.com/docs/build-output-api/v3/configuration#configuration}
66
+ * @protected
67
+ */
68
+ config?: Partial<Omit<VercelOutputConfig, "version">>;
69
+ /**
70
+ * Defaults to `.vercel/output`. Mostly useful for testing purpose
71
+ * @protected
72
+ */
73
+ outDir?: string;
74
+ }
75
+ /**
76
+ * Keys are path relative to .vercel/output/static directory
77
+ */
78
+ type ViteVercelRouteOverrides = VercelOutputConfig["overrides"];
79
+ interface VercelEntryOptions {
80
+ /**
81
+ * If `true`, guesses route for the function, and adds it to config.json (mimics defaults Vercel behavior).
82
+ * If a string is provided, it will be equivalent to a `rewrites` rule.
83
+ * Set to `false` to disable
84
+ */
85
+ route?: string | boolean;
86
+ /**
87
+ * Ensures that the route is added before or after others
88
+ */
89
+ enforce?: "post" | "pre";
90
+ /**
91
+ * Set to `true` to mark this function as an Edge Function
92
+ */
93
+ edge?: boolean;
94
+ /**
95
+ * Additional headers
96
+ */
97
+ headers?: Record<string, string> | null;
98
+ /**
99
+ * ISR config
100
+ */
101
+ isr?: VercelOutputPrerenderConfig;
102
+ /**
103
+ * When true, the Serverless Function will stream the response to the client
104
+ */
105
+ streaming?: boolean;
106
+ }
107
+ //#endregion
108
+ export { PluginContext, VercelEntryOptions, ViteVercelConfig, ViteVercelRedirect, ViteVercelRewrite, ViteVercelRouteOverrides };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ViteVercelConfig } from "./types.js";
2
+
3
+ //#region src/plugins/index.d.ts
4
+ type PluginInterop = Record<string, unknown> & {
5
+ name: string;
6
+ };
7
+ declare function vercel(pluginConfig?: ViteVercelConfig): PluginInterop[];
8
+ //#endregion
9
+ export { vercel as default, vercel };