vite-plugin-vercel 11.0.3 → 11.1.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 CHANGED
@@ -36,6 +36,7 @@ bun add -D vite-plugin-vercel
36
36
  - [ ] [Images optimization](https://vercel.com/docs/build-output-api/v3/configuration#images)
37
37
  - [ ] [Preview mode](https://vercel.com/docs/build-output-api/v3/features#preview-mode)
38
38
  - [x] [Advanced config](/packages/vercel/src/types.ts#L19)
39
+ - [x] [Queues](https://vercel.com/docs/queues)
39
40
 
40
41
  ## Simple usage
41
42
 
@@ -7,6 +7,9 @@ function assert(condition, errorMessage) {
7
7
  //#region src/api.ts
8
8
  function createAPI(outfiles, pluginConfig) {
9
9
  return {
10
+ /**
11
+ * @internal
12
+ */
10
13
  getOutFiles() {
11
14
  return outfiles;
12
15
  },
package/dist/api.d.ts CHANGED
@@ -2,7 +2,7 @@ import { PluginContext, ViteVercelConfig, ViteVercelRedirect, ViteVercelRewrite
2
2
  import { VercelOutputConfig } from "@vite-plugin-vercel/schemas";
3
3
  import { ViteDevServer } from "vite";
4
4
  import { EntryMeta } from "@universal-deploy/store";
5
- import * as _vercel_routing_utils0 from "@vercel/routing-utils";
5
+ import * as _$_vercel_routing_utils0 from "@vercel/routing-utils";
6
6
 
7
7
  //#region src/api.d.ts
8
8
  declare function createAPI(outfiles: ViteVercelOutFile[], pluginConfig: ViteVercelConfig): {
@@ -14,7 +14,7 @@ declare function createAPI(outfiles: ViteVercelOutFile[], pluginConfig: ViteVerc
14
14
  defaultMaxDuration: number | undefined;
15
15
  expiration: number | undefined;
16
16
  readonly rewrites: ViteVercelRewrite[];
17
- readonly headers: _vercel_routing_utils0.Header[];
17
+ readonly headers: _$_vercel_routing_utils0.Header[];
18
18
  readonly redirects: ViteVercelRedirect[];
19
19
  cleanUrls: boolean | undefined;
20
20
  trailingSlash: boolean | undefined;
@@ -29,7 +29,7 @@ declare function getVercelAPI(pluginContextOrServer: Pick<PluginContext, "enviro
29
29
  defaultMaxDuration: number | undefined;
30
30
  expiration: number | undefined;
31
31
  readonly rewrites: ViteVercelRewrite[];
32
- readonly headers: _vercel_routing_utils0.Header[];
32
+ readonly headers: _$_vercel_routing_utils0.Header[];
33
33
  readonly redirects: ViteVercelRedirect[];
34
34
  cleanUrls: boolean | undefined;
35
35
  trailingSlash: boolean | undefined;
package/dist/api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as getVercelAPI, t as createAPI } from "./api-DQ9HQe2a.js";
1
+ import { n as getVercelAPI, t as createAPI } from "./api-DfSs-6Qg.js";
2
2
  export { createAPI, getVercelAPI };
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { VercelOutputConfig, VercelOutputPrerenderConfig } from "@vite-plugin-vercel/schemas";
1
+ import { VercelOutputConfig, VercelOutputPrerenderConfig, VercelOutputQueueTrigger } from "@vite-plugin-vercel/schemas";
2
2
  import { Plugin } from "vite";
3
3
  import { EntryMeta } from "@universal-deploy/store";
4
4
  import { Header, Redirect, Rewrite } from "@vercel/routing-utils";
@@ -10,6 +10,12 @@ type ViteVercelRewrite = Rewrite & {
10
10
  type ViteVercelRedirect = Redirect & {
11
11
  enforce?: "pre" | "post";
12
12
  };
13
+ /**
14
+ * Vercel Queues consumer trigger configuration.
15
+ *
16
+ * @experimental
17
+ */
18
+ type ViteVercelQueueTrigger = VercelOutputQueueTrigger;
13
19
  type PluginContext = ThisParameterType<Extract<Plugin["resolveId"], (...args: never) => any>>;
14
20
  interface ViteVercelConfig {
15
21
  /**
@@ -112,6 +118,18 @@ interface VercelEntryOptions {
112
118
  * When true, the Serverless Function will stream the response to the client
113
119
  */
114
120
  streaming?: boolean;
121
+ /**
122
+ * Configures Vercel Queues consumers. Entries with queue triggers are private, so no public rewrite is generated.
123
+ * Queue consumers must be Serverless Functions; Edge Function builds will throw.
124
+ *
125
+ * @experimental
126
+ */
127
+ experimentalTriggers?: ViteVercelQueueTrigger[];
128
+ }
129
+ declare module "@universal-deploy/store" {
130
+ interface EntryMeta {
131
+ vercel?: VercelEntryOptions;
132
+ }
115
133
  }
116
134
  //#endregion
117
- export { PluginContext, VercelEntryOptions, ViteVercelConfig, ViteVercelRedirect, ViteVercelRewrite, ViteVercelRouteOverrides };
135
+ export { PluginContext, VercelEntryOptions, ViteVercelConfig, ViteVercelQueueTrigger, ViteVercelRedirect, ViteVercelRewrite, ViteVercelRouteOverrides };
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as pathRelativeTo$1 } from "./path-CzW38gOA.js";
2
- import { n as getVercelAPI, r as assert, t as createAPI } from "./api-DQ9HQe2a.js";
2
+ import { n as getVercelAPI, r as assert, t as createAPI } from "./api-DfSs-6Qg.js";
3
3
  import { builtinModules } from "node:module";
4
4
  import path from "node:path";
5
5
  import { vercelOutputConfigSchema, vercelOutputPrerenderConfigSchema, vercelOutputVcConfigSchema } from "@vite-plugin-vercel/schemas";
@@ -524,7 +524,8 @@ function getVcConfig(pluginConfig, filename, options) {
524
524
  maxDuration: pluginConfig.defaultMaxDuration,
525
525
  launcherType: "Nodejs",
526
526
  shouldAddHelpers: false,
527
- supportsResponseStreaming: options.streaming ?? pluginConfig.defaultSupportsResponseStreaming ?? true
527
+ supportsResponseStreaming: options.streaming ?? pluginConfig.defaultSupportsResponseStreaming ?? true,
528
+ experimentalTriggers: options.experimentalTriggers
528
529
  });
529
530
  }
530
531
  //#endregion
@@ -533,18 +534,27 @@ function getOriginalRequest(request) {
533
534
  const xOriginalPath = request.headers.get("x-original-path");
534
535
  let newUrl = null;
535
536
  let newRequest = request;
536
- if (typeof xOriginalPath === "string") newUrl = new URL(xOriginalPath, request.url).toString();
537
- if (newUrl && request.url !== newUrl) newRequest = new Request(newUrl, {
538
- method: request.method,
539
- headers: request.headers,
540
- body: request.body,
541
- mode: request.mode,
542
- credentials: request.credentials,
543
- cache: request.cache,
544
- redirect: request.redirect,
545
- referrer: request.referrer,
546
- integrity: request.integrity
547
- });
537
+ if (typeof xOriginalPath === "string") {
538
+ const requestUrl = new URL(request.url);
539
+ const originalUrl = new URL(xOriginalPath, requestUrl);
540
+ if (!originalUrl.search) originalUrl.search = requestUrl.search;
541
+ newUrl = originalUrl.toString();
542
+ }
543
+ if (newUrl && request.url !== newUrl) {
544
+ const requestInit = {
545
+ method: request.method,
546
+ headers: request.headers,
547
+ body: request.body,
548
+ mode: request.mode,
549
+ credentials: request.credentials,
550
+ cache: request.cache,
551
+ redirect: request.redirect,
552
+ referrer: request.referrer,
553
+ integrity: request.integrity
554
+ };
555
+ if (request.body) requestInit.duplex = "half";
556
+ newRequest = new Request(newUrl, requestInit);
557
+ }
548
558
  return newRequest;
549
559
  }
550
560
  //#endregion
@@ -552,6 +562,10 @@ function getOriginalRequest(request) {
552
562
  const re_DUMMY = new RegExp(`__DUMMY__$`);
553
563
  const re_edge = /[?&]vercel_edge\b/;
554
564
  const re_node = /[?&]vercel_node\b/;
565
+ const queueConsumerEdgeError = "Vercel queue consumers must be serverless functions, not edge functions.";
566
+ function validateQueueConsumersAreServerless(entries) {
567
+ for (const entry of entries) if (entry.vercel?.edge === true && (entry.vercel.experimentalTriggers?.length ?? 0) > 0) throw new Error(queueConsumerEdgeError);
568
+ }
555
569
  function loaderPlugin(pluginConfig) {
556
570
  const envNames = getBuildEnvNames(pluginConfig);
557
571
  let root;
@@ -648,9 +662,10 @@ export default def;`;
648
662
  handler(name) {
649
663
  const isEdge = name === envNames.edge;
650
664
  if (name === envNames.node || isEdge) {
651
- const entries = dedupeRoutes().filter((e) => (e.vercel?.edge ?? false) === isEdge);
665
+ const entries = dedupeRoutes();
666
+ validateQueueConsumersAreServerless(entries);
652
667
  return { build: { rollupOptions: {
653
- input: Object.fromEntries(entries.map((e) => [entryDestination(root ?? process.cwd(), e, ".func/index"), isEdge ? `${e.id}?vercel_edge` : `${e.id}?vercel_node`])),
668
+ input: Object.fromEntries(entries.filter((e) => (e.vercel?.edge ?? false) === isEdge).map((e) => [entryDestination(root ?? process.cwd(), e, ".func/index"), isEdge ? `${e.id}?vercel_edge` : `${e.id}?vercel_node`])),
654
669
  output: {
655
670
  hoistTransitiveImports: false,
656
671
  entryFileNames: "[name].js"
@@ -664,13 +679,15 @@ export default def;`;
664
679
  const nodeVersion = await getNodeVersion(process.cwd());
665
680
  const entries = dedupeRoutes();
666
681
  for (const entry of entries.filter((e) => (e.vercel?.edge ?? false) === isEdge)) {
682
+ const hasExperimentalTriggers = (entry.vercel?.experimentalTriggers?.length ?? 0) > 0;
667
683
  this.emitFile({
668
684
  type: "asset",
669
685
  fileName: entryDestination(root ?? process.cwd(), entry, ".func/.vc-config.json"),
670
686
  source: JSON.stringify(getVcConfig(pluginConfig, isEdge ? "index.js" : "index.mjs", {
671
687
  nodeVersion,
672
688
  edge: isEdge,
673
- streaming: entry.vercel?.streaming
689
+ streaming: entry.vercel?.streaming,
690
+ experimentalTriggers: entry.vercel?.experimentalTriggers
674
691
  }), void 0, 2)
675
692
  });
676
693
  if (entry.vercel?.isr) this.emitFile({
@@ -679,6 +696,7 @@ export default def;`;
679
696
  source: JSON.stringify(vercelOutputPrerenderConfigSchema.parse(entry.vercel.isr), void 0, 2)
680
697
  });
681
698
  pluginConfig.rewrites ??= [];
699
+ if (hasExperimentalTriggers) continue;
682
700
  for (const ir of sortRoutes([entry.route].flat().map((p) => fromRou3(p)))) {
683
701
  const source = toPathToRegexpV6(ir);
684
702
  pluginConfig.rewrites.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vercel",
3
- "version": "11.0.3",
3
+ "version": "11.1.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -24,26 +24,26 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.19.15",
27
- "tsdown": "^0.21.4",
28
- "typescript": "^5.9.3",
29
- "vite": "^7.3.1",
30
- "vitest": "^4.1.0"
27
+ "tsdown": "^0.22.0",
28
+ "typescript": "^6.0.3",
29
+ "vite": "^7.3.3",
30
+ "vitest": "^4.1.5"
31
31
  },
32
32
  "dependencies": {
33
33
  "@manypkg/find-root": "^3.1.0",
34
- "@universal-deploy/store": "^0.2.0",
35
- "@universal-deploy/vite": "^0.1.0",
36
- "@vercel/build-utils": "^13.8.1",
37
- "@vercel/nft": "^1.3.2",
38
- "@vercel/routing-utils": "^6.0.2",
34
+ "@universal-deploy/store": "^0.2.1",
35
+ "@universal-deploy/vite": "^0.1.9",
36
+ "@vercel/build-utils": "^13.22.1",
37
+ "@vercel/nft": "^1.5.0",
38
+ "@vercel/routing-utils": "^6.2.0",
39
39
  "convert-route": "^1.1.1",
40
40
  "fast-glob": "^3.3.3",
41
41
  "magicast": "^0.5.2",
42
- "nf3": "^0.3.11",
43
- "oxc-transform": "^0.120.0",
42
+ "nf3": "^0.3.17",
43
+ "oxc-transform": "^0.129.0",
44
44
  "p-limit": "^7.3.0",
45
- "rolldown": "^1.0.0-rc.9",
46
- "@vite-plugin-vercel/schemas": "^1.1.0"
45
+ "rolldown": "^1.0.0",
46
+ "@vite-plugin-vercel/schemas": "^1.1.1"
47
47
  },
48
48
  "scripts": {
49
49
  "dev": "tsdown --watch",