vite-plugin-vercel 8.0.1 → 9.0.1
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 +24 -8
- package/dist/index.cjs +359 -385
- package/dist/index.d.cts +50 -39
- package/dist/index.d.ts +50 -39
- package/dist/index.js +357 -383
- package/index.d.ts +4 -4
- package/package.json +10 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResolvedConfig, PluginOption } from 'vite';
|
|
2
|
+
import { Rewrite, Redirect, Header } 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?:
|
|
530
|
+
enforce?: "pre" | "post";
|
|
531
531
|
};
|
|
532
532
|
type ViteVercelRedirect = Redirect & {
|
|
533
|
-
enforce?:
|
|
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.
|
|
@@ -555,6 +556,11 @@ interface ViteVercelConfig {
|
|
|
555
556
|
* @see {@link https://vercel.com/docs/projects/project-configuration#rewrites}
|
|
556
557
|
*/
|
|
557
558
|
rewrites?: ViteVercelRewrite[];
|
|
559
|
+
/**
|
|
560
|
+
* @see {@link https://vercel.com/docs/projects/project-configuration#headers}
|
|
561
|
+
* @beta
|
|
562
|
+
*/
|
|
563
|
+
headers?: Header[] | (() => Awaitable<Header[]>);
|
|
558
564
|
/**
|
|
559
565
|
* @see {@link https://vercel.com/docs/projects/project-configuration#redirects}
|
|
560
566
|
*/
|
|
@@ -592,13 +598,13 @@ interface ViteVercelConfig {
|
|
|
592
598
|
* }
|
|
593
599
|
* ```
|
|
594
600
|
*/
|
|
595
|
-
additionalEndpoints?: ViteVercelApiEntry[];
|
|
601
|
+
additionalEndpoints?: (ViteVercelApiEntry | (() => Awaitable<ViteVercelApiEntry>) | (() => Awaitable<ViteVercelApiEntry[]>))[];
|
|
596
602
|
/**
|
|
597
603
|
* Advanced configuration to override .vercel/output/config.json
|
|
598
604
|
* @see {@link https://vercel.com/docs/build-output-api/v3/configuration#configuration}
|
|
599
605
|
* @protected
|
|
600
606
|
*/
|
|
601
|
-
config?: Partial<Omit<VercelOutputConfig,
|
|
607
|
+
config?: Partial<Omit<VercelOutputConfig, "version">>;
|
|
602
608
|
/**
|
|
603
609
|
* ISR and SSG pages are mutually exclusive. If a page is found in both, ISR prevails.
|
|
604
610
|
* Keys are path relative to .vercel/output/functions directory, either without extension,
|
|
@@ -619,7 +625,7 @@ interface ViteVercelConfig {
|
|
|
619
625
|
*
|
|
620
626
|
* @protected
|
|
621
627
|
*/
|
|
622
|
-
isr?: Record<string, VercelOutputIsr> | (() =>
|
|
628
|
+
isr?: Record<string, VercelOutputIsr> | (() => Awaitable<Record<string, VercelOutputIsr>>);
|
|
623
629
|
/**
|
|
624
630
|
* Defaults to `.vercel/output`. Mostly useful for testing purpose
|
|
625
631
|
* @protected
|
|
@@ -629,7 +635,7 @@ interface ViteVercelConfig {
|
|
|
629
635
|
* By default, Vite generates static files under `dist` folder.
|
|
630
636
|
* But usually, when used through a Framework, such as Vike,
|
|
631
637
|
* this folder can contain anything, requiring custom integration.
|
|
632
|
-
* Set this to false
|
|
638
|
+
* Set this to false if you create a plugin for a Framework.
|
|
633
639
|
*/
|
|
634
640
|
distContainsOnlyStatic?: boolean;
|
|
635
641
|
}
|
|
@@ -640,8 +646,8 @@ interface VercelOutputIsr extends VercelOutputPrerenderConfig {
|
|
|
640
646
|
/**
|
|
641
647
|
* Keys are path relative to .vercel/output/static directory
|
|
642
648
|
*/
|
|
643
|
-
type ViteVercelPrerenderRoute = VercelOutputConfig[
|
|
644
|
-
type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) =>
|
|
649
|
+
type ViteVercelPrerenderRoute = VercelOutputConfig["overrides"];
|
|
650
|
+
type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => Awaitable<ViteVercelPrerenderRoute>;
|
|
645
651
|
interface ViteVercelApiEntry {
|
|
646
652
|
/**
|
|
647
653
|
* Path to entry file, or stdin config
|
|
@@ -656,10 +662,15 @@ interface ViteVercelApiEntry {
|
|
|
656
662
|
*/
|
|
657
663
|
buildOptions?: BuildOptions;
|
|
658
664
|
/**
|
|
659
|
-
*
|
|
660
|
-
* Set to `false` to disable
|
|
665
|
+
* @deprecated use `route` instead
|
|
661
666
|
*/
|
|
662
667
|
addRoute?: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* If `true`, guesses route for the function, and adds it to config.json (mimics defaults Vercel behavior).
|
|
670
|
+
* If a string is provided, it will be equivalent to a `rewrites` rule.
|
|
671
|
+
* Set to `false` to disable
|
|
672
|
+
*/
|
|
673
|
+
route?: string | boolean;
|
|
663
674
|
/**
|
|
664
675
|
* Set to `true` to mark this function as an Edge Function
|
|
665
676
|
*/
|
|
@@ -667,7 +678,7 @@ interface ViteVercelApiEntry {
|
|
|
667
678
|
/**
|
|
668
679
|
* Additional headers
|
|
669
680
|
*/
|
|
670
|
-
headers?: Record<string, string
|
|
681
|
+
headers?: Record<string, string> | null;
|
|
671
682
|
/**
|
|
672
683
|
* ISR config
|
|
673
684
|
*/
|
|
@@ -680,4 +691,4 @@ interface ViteVercelApiEntry {
|
|
|
680
691
|
|
|
681
692
|
declare function allPlugins(options?: any): PluginOption[];
|
|
682
693
|
|
|
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 };
|
|
694
|
+
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, Header } 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?:
|
|
530
|
+
enforce?: "pre" | "post";
|
|
531
531
|
};
|
|
532
532
|
type ViteVercelRedirect = Redirect & {
|
|
533
|
-
enforce?:
|
|
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.
|
|
@@ -555,6 +556,11 @@ interface ViteVercelConfig {
|
|
|
555
556
|
* @see {@link https://vercel.com/docs/projects/project-configuration#rewrites}
|
|
556
557
|
*/
|
|
557
558
|
rewrites?: ViteVercelRewrite[];
|
|
559
|
+
/**
|
|
560
|
+
* @see {@link https://vercel.com/docs/projects/project-configuration#headers}
|
|
561
|
+
* @beta
|
|
562
|
+
*/
|
|
563
|
+
headers?: Header[] | (() => Awaitable<Header[]>);
|
|
558
564
|
/**
|
|
559
565
|
* @see {@link https://vercel.com/docs/projects/project-configuration#redirects}
|
|
560
566
|
*/
|
|
@@ -592,13 +598,13 @@ interface ViteVercelConfig {
|
|
|
592
598
|
* }
|
|
593
599
|
* ```
|
|
594
600
|
*/
|
|
595
|
-
additionalEndpoints?: ViteVercelApiEntry[];
|
|
601
|
+
additionalEndpoints?: (ViteVercelApiEntry | (() => Awaitable<ViteVercelApiEntry>) | (() => Awaitable<ViteVercelApiEntry[]>))[];
|
|
596
602
|
/**
|
|
597
603
|
* Advanced configuration to override .vercel/output/config.json
|
|
598
604
|
* @see {@link https://vercel.com/docs/build-output-api/v3/configuration#configuration}
|
|
599
605
|
* @protected
|
|
600
606
|
*/
|
|
601
|
-
config?: Partial<Omit<VercelOutputConfig,
|
|
607
|
+
config?: Partial<Omit<VercelOutputConfig, "version">>;
|
|
602
608
|
/**
|
|
603
609
|
* ISR and SSG pages are mutually exclusive. If a page is found in both, ISR prevails.
|
|
604
610
|
* Keys are path relative to .vercel/output/functions directory, either without extension,
|
|
@@ -619,7 +625,7 @@ interface ViteVercelConfig {
|
|
|
619
625
|
*
|
|
620
626
|
* @protected
|
|
621
627
|
*/
|
|
622
|
-
isr?: Record<string, VercelOutputIsr> | (() =>
|
|
628
|
+
isr?: Record<string, VercelOutputIsr> | (() => Awaitable<Record<string, VercelOutputIsr>>);
|
|
623
629
|
/**
|
|
624
630
|
* Defaults to `.vercel/output`. Mostly useful for testing purpose
|
|
625
631
|
* @protected
|
|
@@ -629,7 +635,7 @@ interface ViteVercelConfig {
|
|
|
629
635
|
* By default, Vite generates static files under `dist` folder.
|
|
630
636
|
* But usually, when used through a Framework, such as Vike,
|
|
631
637
|
* this folder can contain anything, requiring custom integration.
|
|
632
|
-
* Set this to false
|
|
638
|
+
* Set this to false if you create a plugin for a Framework.
|
|
633
639
|
*/
|
|
634
640
|
distContainsOnlyStatic?: boolean;
|
|
635
641
|
}
|
|
@@ -640,8 +646,8 @@ interface VercelOutputIsr extends VercelOutputPrerenderConfig {
|
|
|
640
646
|
/**
|
|
641
647
|
* Keys are path relative to .vercel/output/static directory
|
|
642
648
|
*/
|
|
643
|
-
type ViteVercelPrerenderRoute = VercelOutputConfig[
|
|
644
|
-
type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) =>
|
|
649
|
+
type ViteVercelPrerenderRoute = VercelOutputConfig["overrides"];
|
|
650
|
+
type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => Awaitable<ViteVercelPrerenderRoute>;
|
|
645
651
|
interface ViteVercelApiEntry {
|
|
646
652
|
/**
|
|
647
653
|
* Path to entry file, or stdin config
|
|
@@ -656,10 +662,15 @@ interface ViteVercelApiEntry {
|
|
|
656
662
|
*/
|
|
657
663
|
buildOptions?: BuildOptions;
|
|
658
664
|
/**
|
|
659
|
-
*
|
|
660
|
-
* Set to `false` to disable
|
|
665
|
+
* @deprecated use `route` instead
|
|
661
666
|
*/
|
|
662
667
|
addRoute?: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* If `true`, guesses route for the function, and adds it to config.json (mimics defaults Vercel behavior).
|
|
670
|
+
* If a string is provided, it will be equivalent to a `rewrites` rule.
|
|
671
|
+
* Set to `false` to disable
|
|
672
|
+
*/
|
|
673
|
+
route?: string | boolean;
|
|
663
674
|
/**
|
|
664
675
|
* Set to `true` to mark this function as an Edge Function
|
|
665
676
|
*/
|
|
@@ -667,7 +678,7 @@ interface ViteVercelApiEntry {
|
|
|
667
678
|
/**
|
|
668
679
|
* Additional headers
|
|
669
680
|
*/
|
|
670
|
-
headers?: Record<string, string
|
|
681
|
+
headers?: Record<string, string> | null;
|
|
671
682
|
/**
|
|
672
683
|
* ISR config
|
|
673
684
|
*/
|
|
@@ -680,4 +691,4 @@ interface ViteVercelApiEntry {
|
|
|
680
691
|
|
|
681
692
|
declare function allPlugins(options?: any): PluginOption[];
|
|
682
693
|
|
|
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 };
|
|
694
|
+
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 };
|