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

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 CHANGED
@@ -1,14 +1,15 @@
1
1
  # vite-plugin-vercel
2
2
 
3
- > [!WARNING]
4
- > :construction: Work In Progress
5
- >
6
- > You are on the [Vite Environment API](https://vite.dev/guide/api-environment.html#environment-configuration) development branch. Check out [v9 branch](https://github.com/magne4000/vite-plugin-vercel/tree/v9) current stable version.
3
+ > [!NOTE]
4
+ > You are on the [Vite Environment API](https://vite.dev/guide/api-environment.html#environment-configuration) beta branch (v10). Check out [v9 branch](https://github.com/magne4000/vite-plugin-vercel/tree/v9) for current stable version.
7
5
 
8
- Vercel adapter for [Vite 6](https://vitejs.dev/).
6
+ Vercel adapter for [Vite](https://vitejs.dev/).
9
7
 
10
8
  Bundle your Vite application as supported by [Vercel Output API (v3)](https://vercel.com/docs/build-output-api/v3).
11
9
 
10
+ > [!NOTE]
11
+ > This plugin is mostly a re-export of [`@photonjs/vercel`](https://github.com/photon-js/photon/tree/main/packages/adapter-vercel)
12
+
12
13
  ## Install
13
14
 
14
15
  ```bash
@@ -52,16 +53,16 @@ import { defineConfig } from 'vite';
52
53
  import vercel from 'vite-plugin-vercel';
53
54
  import { getEntriesFromFs } from "vite-plugin-vercel/utils";
54
55
 
56
+ const entries = await getEntriesFromFs("endpoints/api", {
57
+ // Auto mapping examples:
58
+ // endpoints/api/page.ts -> /api/page
59
+ // endpoints/api/name/[name].ts -> /api/name/*
60
+ destination: "api",
61
+ });
62
+
55
63
  export default defineConfig({
56
64
  plugins: [vercel({
57
- entries: [
58
- ...(await getEntriesFromFs("endpoints/api", {
59
- // Auto mapping examples:
60
- // endpoints/api/page.ts -> /api/page
61
- // endpoints/api/name/[name].ts -> /api/name/*
62
- destination: "api",
63
- }))
64
- ]
65
+ entries,
65
66
  })],
66
67
  });
67
68
  ```
@@ -104,6 +105,95 @@ export default async function handler() {
104
105
 
105
106
  You can use [Edge middleware as describe in the official documentation](https://vercel.com/docs/functions/edge-middleware/middleware-api) (i.e. with a `middleware.ts` file at the root of your project).
106
107
 
108
+ ## Advanced settings
109
+
110
+ ```ts
111
+ // vite.config.ts
112
+ import { defineConfig } from 'vite';
113
+ import vercel from 'vite-plugin-vercel';
114
+
115
+ export default defineConfig({
116
+ plugins: [vercel({
117
+ // All the followings optional
118
+
119
+ /**
120
+ * How long Functions should be allowed to run for every request, in seconds.
121
+ * If left empty, default value for your plan will be used.
122
+ */
123
+ defaultMaxDuration: 30,
124
+ /**
125
+ * Enable streaming responses by default for all Serverless Functions
126
+ */
127
+ defaultSupportsResponseStreaming: true,
128
+ /**
129
+ * Default expiration time (in seconds) for prerender functions.
130
+ * Defaults to 86400 seconds (24h).
131
+ */
132
+ expiration: 86400,
133
+
134
+ /**
135
+ * See https://vercel.com/docs/projects/project-configuration#rewrites
136
+ */
137
+ rewrites: [{ source: '/about', destination: '/about-our-company.html' }],
138
+ /**
139
+ * @see {@link https://vercel.com/docs/projects/project-configuration#headers}
140
+ */
141
+ headers: [
142
+ {
143
+ "source": "/service-worker.js",
144
+ "headers": [
145
+ {
146
+ "key": "Cache-Control",
147
+ "value": "public, max-age=0, must-revalidate"
148
+ }
149
+ ]
150
+ }
151
+ ],
152
+ /**
153
+ * See https://vercel.com/docs/projects/project-configuration#redirects
154
+ */
155
+ redirects: [
156
+ { source: '/me', destination: '/profile.html', permanent: false },
157
+ ],
158
+ /**
159
+ * See https://vercel.com/docs/projects/project-configuration#cleanurls
160
+ */
161
+ cleanUrls: true,
162
+ /**
163
+ * See https://vercel.com/docs/projects/project-configuration#trailingslash
164
+ */
165
+ trailingSlash: true,
166
+ /**
167
+ * Use `getEntriesFromFs` for mapping your filesystem routes to entries.
168
+ * If you are interfacing this plugin with a framework, entries can also be added through the Photon API
169
+ */
170
+ entries: {
171
+ root: {
172
+ id: 'src/routes/root.ts',
173
+ name: 'root',
174
+ route: '/'
175
+ }
176
+ },
177
+ /**
178
+ * Advanced configuration to override .vercel/output/config.json
179
+ * See https://vercel.com/docs/build-output-api/v3/configuration#configuration
180
+ */
181
+ config: {
182
+ // routes?: Route[];
183
+ // images?: ImagesConfig;
184
+ // wildcard?: WildcardConfig;
185
+ // overrides?: OverrideConfig;
186
+ // cache?: string[];
187
+ // crons?: CronsConfig;
188
+ },
189
+ /**
190
+ * Defaults to `.vercel/output`. Mostly useful for testing purpose
191
+ */
192
+ outDir: '.vercel/output',
193
+ })]
194
+ });
195
+ ```
196
+
107
197
  ## FAQ
108
198
 
109
199
  ### What does ISR do in dev mode?
@@ -117,6 +207,10 @@ This is not yet supported. Please open an issue if you need this (PR welcome).
117
207
 
118
208
  Related documentation: https://vercel.com/docs/edge-network/headers/request-headers
119
209
 
120
- ## Migration from v9
210
+ ## Migrations
211
+
212
+ - [Migration from v9 to v10](https://github.com/magne4000/vite-plugin-vercel/blob/main/MIGRATION.md)
213
+
214
+ ## Demo
121
215
 
122
- TODO
216
+ https://vike-photon-demo.vercel.app/
package/dist/api.d.ts CHANGED
@@ -1,55 +1 @@
1
- /// <reference types="@photonjs/core" />
2
-
3
- import * as _vercel_routing_utils from '@vercel/routing-utils';
4
- import { ViteVercelConfig, ViteVercelRewrite, ViteVercelRedirect } from './types.js';
5
- import { PluginContext } from 'rollup';
6
- import { ViteDevServer } from 'vite';
7
- import { Photon } from '@photonjs/core';
8
- import { VercelOutputConfig } from '@vite-plugin-vercel/schemas';
9
-
10
- declare function createAPI(outfiles: ViteVercelOutFile[], pluginConfig: ViteVercelConfig): {
11
- /**
12
- * @internal
13
- */
14
- getOutFiles(): ViteVercelOutFile[];
15
- readonly config: Partial<Omit<VercelOutputConfig, "version">>;
16
- defaultMaxDuration: number | undefined;
17
- expiration: number | undefined;
18
- readonly rewrites: ViteVercelRewrite[];
19
- readonly headers: _vercel_routing_utils.Header[];
20
- readonly redirects: ViteVercelRedirect[];
21
- cleanUrls: boolean | undefined;
22
- trailingSlash: boolean | undefined;
23
- defaultSupportsResponseStreaming: boolean | undefined;
24
- };
25
- declare function getVercelAPI(pluginContextOrServer: PluginContext | ViteDevServer): {
26
- /**
27
- * @internal
28
- */
29
- getOutFiles(): ViteVercelOutFile[];
30
- readonly config: Partial<Omit<VercelOutputConfig, "version">>;
31
- defaultMaxDuration: number | undefined;
32
- expiration: number | undefined;
33
- readonly rewrites: ViteVercelRewrite[];
34
- readonly headers: _vercel_routing_utils.Header[];
35
- readonly redirects: ViteVercelRedirect[];
36
- cleanUrls: boolean | undefined;
37
- trailingSlash: boolean | undefined;
38
- defaultSupportsResponseStreaming: boolean | undefined;
39
- };
40
- type ViteVercelApi = ReturnType<typeof createAPI>;
41
- type ViteVercelOutFile = ViteVercelOutFileChunk | ViteVercelOutFileAsset;
42
- interface ViteVercelOutFileCommon {
43
- filepath: string;
44
- root: string;
45
- outdir: string;
46
- }
47
- interface ViteVercelOutFileChunk extends ViteVercelOutFileCommon {
48
- type: "chunk";
49
- relatedEntry: Photon.Entry;
50
- }
51
- interface ViteVercelOutFileAsset extends ViteVercelOutFileCommon {
52
- type: "asset";
53
- }
54
-
55
- export { type ViteVercelApi, type ViteVercelOutFile, type ViteVercelOutFileAsset, type ViteVercelOutFileChunk, createAPI, getVercelAPI };
1
+ export * from '@photonjs/vercel/api';
package/dist/api.js CHANGED
@@ -1,9 +1,2 @@
1
- import {
2
- createAPI,
3
- getVercelAPI
4
- } from "./chunk-CR7Q2T4Q.js";
5
- import "./chunk-UTQ72LMT.js";
6
- export {
7
- createAPI,
8
- getVercelAPI
9
- };
1
+ // src/api.ts
2
+ export * from "@photonjs/vercel/api";
package/dist/index.d.ts CHANGED
@@ -1,11 +1,5 @@
1
- /// <reference types="@photonjs/core" />
1
+ import plugin from '@photonjs/vercel/vite';
2
2
 
3
- import { PluginOption } from 'vite';
4
- import { ViteVercelConfig } from './types.js';
5
- import '@photonjs/core';
6
- import '@vercel/routing-utils';
7
- import '@vite-plugin-vercel/schemas';
8
-
9
- declare function vercel(pluginConfig?: ViteVercelConfig): PluginOption[];
3
+ declare const vercel: typeof plugin;
10
4
 
11
5
  export { vercel as default, vercel };