vite-plugin-vercel 8.0.0 → 9.0.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/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ResolvedConfig, PluginOption } from 'vite';
2
+ import { Rewrite, Redirect } from '@vercel/routing-utils';
2
3
  import { StdinOptions, BuildOptions } from 'esbuild';
3
4
  import { z } from 'zod';
4
- import { Rewrite, Redirect } from '@vercel/routing-utils';
5
5
 
6
6
  /**
7
7
  * Schema definition for `.vercel/output/config.json`
@@ -413,6 +413,32 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
413
413
  }>;
414
414
  type VercelOutputConfig = z.infer<typeof vercelOutputConfigSchema>;
415
415
 
416
+ /**
417
+ * Schema definition for `.vercel/output/config.json`
418
+ * @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
419
+ */
420
+
421
+ declare const vercelOutputPrerenderConfigSchema: z.ZodObject<{
422
+ expiration: z.ZodUnion<[z.ZodNumber, z.ZodLiteral<false>]>;
423
+ group: z.ZodOptional<z.ZodNumber>;
424
+ bypassToken: z.ZodOptional<z.ZodString>;
425
+ fallback: z.ZodOptional<z.ZodString>;
426
+ allowQuery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
427
+ }, "strict", z.ZodTypeAny, {
428
+ expiration: number | false;
429
+ group?: number | undefined;
430
+ bypassToken?: string | undefined;
431
+ fallback?: string | undefined;
432
+ allowQuery?: string[] | undefined;
433
+ }, {
434
+ expiration: number | false;
435
+ group?: number | undefined;
436
+ bypassToken?: string | undefined;
437
+ fallback?: string | undefined;
438
+ allowQuery?: string[] | undefined;
439
+ }>;
440
+ type VercelOutputPrerenderConfig = z.infer<typeof vercelOutputPrerenderConfigSchema>;
441
+
416
442
  /**
417
443
  * Schema definition for `.vercel/output/functions/<name>.func/.vc-config.json`
418
444
  * @see {@link https://vercel.com/docs/build-output-api/v3/primitives#serverless-function-configuration}
@@ -500,38 +526,13 @@ declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
500
526
  }>]>;
501
527
  type VercelOutputVcConfig = z.infer<typeof vercelOutputVcConfigSchema>;
502
528
 
503
- /**
504
- * Schema definition for `.vercel/output/config.json`
505
- * @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
506
- */
507
-
508
- declare const vercelOutputPrerenderConfigSchema: z.ZodObject<{
509
- expiration: z.ZodUnion<[z.ZodNumber, z.ZodLiteral<false>]>;
510
- group: z.ZodOptional<z.ZodNumber>;
511
- bypassToken: z.ZodOptional<z.ZodString>;
512
- fallback: z.ZodOptional<z.ZodString>;
513
- allowQuery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
514
- }, "strict", z.ZodTypeAny, {
515
- expiration: number | false;
516
- group?: number | undefined;
517
- bypassToken?: string | undefined;
518
- fallback?: string | undefined;
519
- allowQuery?: string[] | undefined;
520
- }, {
521
- expiration: number | false;
522
- group?: number | undefined;
523
- bypassToken?: string | undefined;
524
- fallback?: string | undefined;
525
- allowQuery?: string[] | undefined;
526
- }>;
527
- type VercelOutputPrerenderConfig = z.infer<typeof vercelOutputPrerenderConfigSchema>;
528
-
529
529
  type ViteVercelRewrite = Rewrite & {
530
- enforce?: 'pre' | 'post';
530
+ enforce?: "pre" | "post";
531
531
  };
532
532
  type ViteVercelRedirect = Redirect & {
533
- enforce?: 'pre' | 'post';
533
+ enforce?: "pre" | "post";
534
534
  };
535
+ type Awaitable<T> = T | Promise<T>;
535
536
  interface ViteVercelConfig {
536
537
  /**
537
538
  * How long Functions should be allowed to run for every request, in seconds.
@@ -592,13 +593,13 @@ interface ViteVercelConfig {
592
593
  * }
593
594
  * ```
594
595
  */
595
- additionalEndpoints?: ViteVercelApiEntry[];
596
+ additionalEndpoints?: (ViteVercelApiEntry | (() => Awaitable<ViteVercelApiEntry>) | (() => Awaitable<ViteVercelApiEntry[]>))[];
596
597
  /**
597
598
  * Advanced configuration to override .vercel/output/config.json
598
599
  * @see {@link https://vercel.com/docs/build-output-api/v3/configuration#configuration}
599
600
  * @protected
600
601
  */
601
- config?: Partial<Omit<VercelOutputConfig, 'version'>>;
602
+ config?: Partial<Omit<VercelOutputConfig, "version">>;
602
603
  /**
603
604
  * ISR and SSG pages are mutually exclusive. If a page is found in both, ISR prevails.
604
605
  * Keys are path relative to .vercel/output/functions directory, either without extension,
@@ -619,7 +620,7 @@ interface ViteVercelConfig {
619
620
  *
620
621
  * @protected
621
622
  */
622
- isr?: Record<string, VercelOutputIsr> | (() => Promise<Record<string, VercelOutputIsr>> | Record<string, VercelOutputIsr>);
623
+ isr?: Record<string, VercelOutputIsr> | (() => Awaitable<Record<string, VercelOutputIsr>>);
623
624
  /**
624
625
  * Defaults to `.vercel/output`. Mostly useful for testing purpose
625
626
  * @protected
@@ -629,7 +630,7 @@ interface ViteVercelConfig {
629
630
  * By default, Vite generates static files under `dist` folder.
630
631
  * But usually, when used through a Framework, such as Vike,
631
632
  * this folder can contain anything, requiring custom integration.
632
- * Set this to false is you create a plugin for a Framework.
633
+ * Set this to false if you create a plugin for a Framework.
633
634
  */
634
635
  distContainsOnlyStatic?: boolean;
635
636
  }
@@ -640,8 +641,8 @@ interface VercelOutputIsr extends VercelOutputPrerenderConfig {
640
641
  /**
641
642
  * Keys are path relative to .vercel/output/static directory
642
643
  */
643
- type ViteVercelPrerenderRoute = VercelOutputConfig['overrides'];
644
- type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => ViteVercelPrerenderRoute | Promise<ViteVercelPrerenderRoute>;
644
+ type ViteVercelPrerenderRoute = VercelOutputConfig["overrides"];
645
+ type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => Awaitable<ViteVercelPrerenderRoute>;
645
646
  interface ViteVercelApiEntry {
646
647
  /**
647
648
  * Path to entry file, or stdin config
@@ -656,10 +657,15 @@ interface ViteVercelApiEntry {
656
657
  */
657
658
  buildOptions?: BuildOptions;
658
659
  /**
659
- * Automatically add a route for the function (mimics defaults Vercel behavior)
660
- * Set to `false` to disable
660
+ * @deprecated use `route` instead
661
661
  */
662
662
  addRoute?: boolean;
663
+ /**
664
+ * If `true`, guesses route for the function, and adds it to config.json (mimics defaults Vercel behavior).
665
+ * If a string is provided, it will be equivalent to a `rewrites` rule.
666
+ * Set to `false` to disable
667
+ */
668
+ route?: string | boolean;
663
669
  /**
664
670
  * Set to `true` to mark this function as an Edge Function
665
671
  */
@@ -680,4 +686,4 @@ interface ViteVercelApiEntry {
680
686
 
681
687
  declare function allPlugins(options?: any): PluginOption[];
682
688
 
683
- export { type VercelOutputConfig, type VercelOutputIsr, type VercelOutputPrerenderConfig, type VercelOutputVcConfig, type ViteVercelApiEntry, type ViteVercelConfig, type ViteVercelPrerenderFn, type ViteVercelPrerenderRoute, type ViteVercelRedirect, type ViteVercelRewrite, allPlugins as default };
689
+ export { type Awaitable, type VercelOutputConfig, type VercelOutputIsr, type VercelOutputPrerenderConfig, type VercelOutputVcConfig, type ViteVercelApiEntry, type ViteVercelConfig, type ViteVercelPrerenderFn, type ViteVercelPrerenderRoute, type ViteVercelRedirect, type ViteVercelRewrite, allPlugins as default };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ResolvedConfig, PluginOption } from 'vite';
2
+ import { Rewrite, Redirect } from '@vercel/routing-utils';
2
3
  import { StdinOptions, BuildOptions } from 'esbuild';
3
4
  import { z } from 'zod';
4
- import { Rewrite, Redirect } from '@vercel/routing-utils';
5
5
 
6
6
  /**
7
7
  * Schema definition for `.vercel/output/config.json`
@@ -413,6 +413,32 @@ declare const vercelOutputConfigSchema: z.ZodObject<{
413
413
  }>;
414
414
  type VercelOutputConfig = z.infer<typeof vercelOutputConfigSchema>;
415
415
 
416
+ /**
417
+ * Schema definition for `.vercel/output/config.json`
418
+ * @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
419
+ */
420
+
421
+ declare const vercelOutputPrerenderConfigSchema: z.ZodObject<{
422
+ expiration: z.ZodUnion<[z.ZodNumber, z.ZodLiteral<false>]>;
423
+ group: z.ZodOptional<z.ZodNumber>;
424
+ bypassToken: z.ZodOptional<z.ZodString>;
425
+ fallback: z.ZodOptional<z.ZodString>;
426
+ allowQuery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
427
+ }, "strict", z.ZodTypeAny, {
428
+ expiration: number | false;
429
+ group?: number | undefined;
430
+ bypassToken?: string | undefined;
431
+ fallback?: string | undefined;
432
+ allowQuery?: string[] | undefined;
433
+ }, {
434
+ expiration: number | false;
435
+ group?: number | undefined;
436
+ bypassToken?: string | undefined;
437
+ fallback?: string | undefined;
438
+ allowQuery?: string[] | undefined;
439
+ }>;
440
+ type VercelOutputPrerenderConfig = z.infer<typeof vercelOutputPrerenderConfigSchema>;
441
+
416
442
  /**
417
443
  * Schema definition for `.vercel/output/functions/<name>.func/.vc-config.json`
418
444
  * @see {@link https://vercel.com/docs/build-output-api/v3/primitives#serverless-function-configuration}
@@ -500,38 +526,13 @@ declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
500
526
  }>]>;
501
527
  type VercelOutputVcConfig = z.infer<typeof vercelOutputVcConfigSchema>;
502
528
 
503
- /**
504
- * Schema definition for `.vercel/output/config.json`
505
- * @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
506
- */
507
-
508
- declare const vercelOutputPrerenderConfigSchema: z.ZodObject<{
509
- expiration: z.ZodUnion<[z.ZodNumber, z.ZodLiteral<false>]>;
510
- group: z.ZodOptional<z.ZodNumber>;
511
- bypassToken: z.ZodOptional<z.ZodString>;
512
- fallback: z.ZodOptional<z.ZodString>;
513
- allowQuery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
514
- }, "strict", z.ZodTypeAny, {
515
- expiration: number | false;
516
- group?: number | undefined;
517
- bypassToken?: string | undefined;
518
- fallback?: string | undefined;
519
- allowQuery?: string[] | undefined;
520
- }, {
521
- expiration: number | false;
522
- group?: number | undefined;
523
- bypassToken?: string | undefined;
524
- fallback?: string | undefined;
525
- allowQuery?: string[] | undefined;
526
- }>;
527
- type VercelOutputPrerenderConfig = z.infer<typeof vercelOutputPrerenderConfigSchema>;
528
-
529
529
  type ViteVercelRewrite = Rewrite & {
530
- enforce?: 'pre' | 'post';
530
+ enforce?: "pre" | "post";
531
531
  };
532
532
  type ViteVercelRedirect = Redirect & {
533
- enforce?: 'pre' | 'post';
533
+ enforce?: "pre" | "post";
534
534
  };
535
+ type Awaitable<T> = T | Promise<T>;
535
536
  interface ViteVercelConfig {
536
537
  /**
537
538
  * How long Functions should be allowed to run for every request, in seconds.
@@ -592,13 +593,13 @@ interface ViteVercelConfig {
592
593
  * }
593
594
  * ```
594
595
  */
595
- additionalEndpoints?: ViteVercelApiEntry[];
596
+ additionalEndpoints?: (ViteVercelApiEntry | (() => Awaitable<ViteVercelApiEntry>) | (() => Awaitable<ViteVercelApiEntry[]>))[];
596
597
  /**
597
598
  * Advanced configuration to override .vercel/output/config.json
598
599
  * @see {@link https://vercel.com/docs/build-output-api/v3/configuration#configuration}
599
600
  * @protected
600
601
  */
601
- config?: Partial<Omit<VercelOutputConfig, 'version'>>;
602
+ config?: Partial<Omit<VercelOutputConfig, "version">>;
602
603
  /**
603
604
  * ISR and SSG pages are mutually exclusive. If a page is found in both, ISR prevails.
604
605
  * Keys are path relative to .vercel/output/functions directory, either without extension,
@@ -619,7 +620,7 @@ interface ViteVercelConfig {
619
620
  *
620
621
  * @protected
621
622
  */
622
- isr?: Record<string, VercelOutputIsr> | (() => Promise<Record<string, VercelOutputIsr>> | Record<string, VercelOutputIsr>);
623
+ isr?: Record<string, VercelOutputIsr> | (() => Awaitable<Record<string, VercelOutputIsr>>);
623
624
  /**
624
625
  * Defaults to `.vercel/output`. Mostly useful for testing purpose
625
626
  * @protected
@@ -629,7 +630,7 @@ interface ViteVercelConfig {
629
630
  * By default, Vite generates static files under `dist` folder.
630
631
  * But usually, when used through a Framework, such as Vike,
631
632
  * this folder can contain anything, requiring custom integration.
632
- * Set this to false is you create a plugin for a Framework.
633
+ * Set this to false if you create a plugin for a Framework.
633
634
  */
634
635
  distContainsOnlyStatic?: boolean;
635
636
  }
@@ -640,8 +641,8 @@ interface VercelOutputIsr extends VercelOutputPrerenderConfig {
640
641
  /**
641
642
  * Keys are path relative to .vercel/output/static directory
642
643
  */
643
- type ViteVercelPrerenderRoute = VercelOutputConfig['overrides'];
644
- type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => ViteVercelPrerenderRoute | Promise<ViteVercelPrerenderRoute>;
644
+ type ViteVercelPrerenderRoute = VercelOutputConfig["overrides"];
645
+ type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => Awaitable<ViteVercelPrerenderRoute>;
645
646
  interface ViteVercelApiEntry {
646
647
  /**
647
648
  * Path to entry file, or stdin config
@@ -656,10 +657,15 @@ interface ViteVercelApiEntry {
656
657
  */
657
658
  buildOptions?: BuildOptions;
658
659
  /**
659
- * Automatically add a route for the function (mimics defaults Vercel behavior)
660
- * Set to `false` to disable
660
+ * @deprecated use `route` instead
661
661
  */
662
662
  addRoute?: boolean;
663
+ /**
664
+ * If `true`, guesses route for the function, and adds it to config.json (mimics defaults Vercel behavior).
665
+ * If a string is provided, it will be equivalent to a `rewrites` rule.
666
+ * Set to `false` to disable
667
+ */
668
+ route?: string | boolean;
663
669
  /**
664
670
  * Set to `true` to mark this function as an Edge Function
665
671
  */
@@ -680,4 +686,4 @@ interface ViteVercelApiEntry {
680
686
 
681
687
  declare function allPlugins(options?: any): PluginOption[];
682
688
 
683
- export { type VercelOutputConfig, type VercelOutputIsr, type VercelOutputPrerenderConfig, type VercelOutputVcConfig, type ViteVercelApiEntry, type ViteVercelConfig, type ViteVercelPrerenderFn, type ViteVercelPrerenderRoute, type ViteVercelRedirect, type ViteVercelRewrite, allPlugins as default };
689
+ export { type Awaitable, type VercelOutputConfig, type VercelOutputIsr, type VercelOutputPrerenderConfig, type VercelOutputVcConfig, type ViteVercelApiEntry, type ViteVercelConfig, type ViteVercelPrerenderFn, type ViteVercelPrerenderRoute, type ViteVercelRedirect, type ViteVercelRewrite, allPlugins as default };