vite-plugin-vercel 2.0.0 → 3.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/README.md +6 -5
- package/dist/index.cjs +23 -23
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Bundle your Vite application as supported by [Vercel Output API (v3)](https://ve
|
|
|
14
14
|
- [x] [ISR/Prerender functions](https://vercel.com/docs/build-output-api/v3/primitives#prerender-functions)
|
|
15
15
|
- see [`isr` config](/packages/vercel/src/types.ts#L89). Also see implementation of [vike](/packages/vike-integration/vike.ts) for example
|
|
16
16
|
- [x] [Edge functions](https://vercel.com/docs/build-output-api/v3/primitives#edge-functions)
|
|
17
|
-
- [
|
|
17
|
+
- [x] [Edge middleware](https://vercel.com/docs/functions/edge-middleware/middleware-api)
|
|
18
18
|
- [ ] [Images optimization](https://vercel.com/docs/build-output-api/v3/configuration#images)
|
|
19
19
|
- [ ] [Preview mode](https://vercel.com/docs/build-output-api/v3/features#preview-mode)
|
|
20
20
|
- [x] [Advanced config](/packages/vercel/src/types.ts#L19)
|
|
@@ -72,6 +72,10 @@ export default async function handler() {
|
|
|
72
72
|
> [!NOTE]
|
|
73
73
|
> Please create an issue if you need other per-endpoints configurations
|
|
74
74
|
|
|
75
|
+
### Edge middleware
|
|
76
|
+
|
|
77
|
+
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).
|
|
78
|
+
|
|
75
79
|
## Usage with vike
|
|
76
80
|
|
|
77
81
|
[vike](https://vike.dev/) is supported through [@vite-plugin-vercel/vike](/packages/vike-integration/README.md) plugin.
|
|
@@ -82,10 +86,7 @@ You only need to install `@vite-plugin-vercel/vike`, the Vite config stays the s
|
|
|
82
86
|
> `@vite-plugin-vercel/vike` supersedes the old `@magne4000/vite-plugin-vercel-ssr` package.
|
|
83
87
|
> As such, you should remove `@magne4000/vite-plugin-vercel-ssr` from your package.json and vite config file.
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`vite-plugin-vercel` fully supports [vike V1 design](https://vike.dev/migration/v1-design),
|
|
88
|
-
and thus you can leverage [config files](https://vike.dev/config) to customize ISR configuration:
|
|
89
|
+
You can then leverage [config files](https://vike.dev/config) to customize ISR configuration:
|
|
89
90
|
|
|
90
91
|
```ts
|
|
91
92
|
// /pages/product/+config.h.ts
|
package/dist/index.cjs
CHANGED
|
@@ -468,20 +468,20 @@ async function removeDefaultExport(filepath) {
|
|
|
468
468
|
}
|
|
469
469
|
async function extractExports(filepath) {
|
|
470
470
|
var _a;
|
|
471
|
-
const contents = await removeDefaultExport(filepath);
|
|
472
|
-
const buildOptions = {
|
|
473
|
-
...standardBuildOptions,
|
|
474
|
-
minify: false,
|
|
475
|
-
write: false,
|
|
476
|
-
legalComments: "none"
|
|
477
|
-
};
|
|
478
|
-
buildOptions.stdin = {
|
|
479
|
-
sourcefile: filepath,
|
|
480
|
-
contents,
|
|
481
|
-
loader: filepath.endsWith(".ts") ? "ts" : filepath.endsWith(".tsx") ? "tsx" : filepath.endsWith(".js") ? "js" : filepath.endsWith(".jsx") ? "jsx" : "default",
|
|
482
|
-
resolveDir: (0, import_path3.dirname)(filepath)
|
|
483
|
-
};
|
|
484
471
|
try {
|
|
472
|
+
const contents = await removeDefaultExport(filepath);
|
|
473
|
+
const buildOptions = {
|
|
474
|
+
...standardBuildOptions,
|
|
475
|
+
minify: false,
|
|
476
|
+
write: false,
|
|
477
|
+
legalComments: "none"
|
|
478
|
+
};
|
|
479
|
+
buildOptions.stdin = {
|
|
480
|
+
sourcefile: filepath,
|
|
481
|
+
contents,
|
|
482
|
+
loader: filepath.endsWith(".ts") ? "ts" : filepath.endsWith(".tsx") ? "tsx" : filepath.endsWith(".js") ? "js" : filepath.endsWith(".jsx") ? "jsx" : "default",
|
|
483
|
+
resolveDir: (0, import_path3.dirname)(filepath)
|
|
484
|
+
};
|
|
485
485
|
const output = await (0, import_esbuild.build)(buildOptions);
|
|
486
486
|
const bundle = new TextDecoder().decode((_a = output.outputFiles[0]) == null ? void 0 : _a.contents);
|
|
487
487
|
return vercelEndpointExports.parse((0, import_eval.default)(bundle, filepath, {}, true));
|
|
@@ -493,29 +493,29 @@ async function buildEndpoints(resolvedConfig) {
|
|
|
493
493
|
const entries = getEntries(resolvedConfig);
|
|
494
494
|
for (const entry of entries) {
|
|
495
495
|
if (typeof entry.source === "string") {
|
|
496
|
-
const
|
|
497
|
-
if (
|
|
498
|
-
if (entry.headers ||
|
|
496
|
+
const exports2 = await extractExports(entry.source);
|
|
497
|
+
if (exports2) {
|
|
498
|
+
if (entry.headers || exports2.headers) {
|
|
499
499
|
entry.headers = {
|
|
500
|
-
...
|
|
500
|
+
...exports2.headers,
|
|
501
501
|
...entry.headers
|
|
502
502
|
};
|
|
503
503
|
}
|
|
504
|
-
if (entry.edge !== void 0 &&
|
|
504
|
+
if (entry.edge !== void 0 && exports2.edge !== void 0) {
|
|
505
505
|
throw new Error(
|
|
506
506
|
`edge configuration should be defined either in the endpoint itself or through Vite config, not both ('${entry.source}')`
|
|
507
507
|
);
|
|
508
508
|
}
|
|
509
|
-
if (
|
|
510
|
-
entry.edge =
|
|
509
|
+
if (exports2.edge !== void 0) {
|
|
510
|
+
entry.edge = exports2.edge;
|
|
511
511
|
}
|
|
512
|
-
if (entry.isr !== void 0 &&
|
|
512
|
+
if (entry.isr !== void 0 && exports2.isr !== void 0) {
|
|
513
513
|
throw new Error(
|
|
514
514
|
`isr configuration should be defined either in the endpoint itself or through Vite config, not both ('${entry.source}')`
|
|
515
515
|
);
|
|
516
516
|
}
|
|
517
|
-
if (
|
|
518
|
-
entry.isr =
|
|
517
|
+
if (exports2.isr) {
|
|
518
|
+
entry.isr = exports2.isr;
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
521
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -653,4 +653,4 @@ declare function allPlugins(options?: {
|
|
|
653
653
|
smart?: boolean;
|
|
654
654
|
}): PluginOption[];
|
|
655
655
|
|
|
656
|
-
export { VercelOutputConfig, VercelOutputIsr, VercelOutputPrerenderConfig, VercelOutputVcConfig, ViteVercelApiEntry, ViteVercelConfig, ViteVercelPrerenderFn, ViteVercelPrerenderRoute, ViteVercelRedirect, ViteVercelRewrite, allPlugins as default };
|
|
656
|
+
export { 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
|
@@ -653,4 +653,4 @@ declare function allPlugins(options?: {
|
|
|
653
653
|
smart?: boolean;
|
|
654
654
|
}): PluginOption[];
|
|
655
655
|
|
|
656
|
-
export { VercelOutputConfig, VercelOutputIsr, VercelOutputPrerenderConfig, VercelOutputVcConfig, ViteVercelApiEntry, ViteVercelConfig, ViteVercelPrerenderFn, ViteVercelPrerenderRoute, ViteVercelRedirect, ViteVercelRewrite, allPlugins as default };
|
|
656
|
+
export { 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.js
CHANGED
|
@@ -438,20 +438,20 @@ async function removeDefaultExport(filepath) {
|
|
|
438
438
|
}
|
|
439
439
|
async function extractExports(filepath) {
|
|
440
440
|
var _a;
|
|
441
|
-
const contents = await removeDefaultExport(filepath);
|
|
442
|
-
const buildOptions = {
|
|
443
|
-
...standardBuildOptions,
|
|
444
|
-
minify: false,
|
|
445
|
-
write: false,
|
|
446
|
-
legalComments: "none"
|
|
447
|
-
};
|
|
448
|
-
buildOptions.stdin = {
|
|
449
|
-
sourcefile: filepath,
|
|
450
|
-
contents,
|
|
451
|
-
loader: filepath.endsWith(".ts") ? "ts" : filepath.endsWith(".tsx") ? "tsx" : filepath.endsWith(".js") ? "js" : filepath.endsWith(".jsx") ? "jsx" : "default",
|
|
452
|
-
resolveDir: dirname(filepath)
|
|
453
|
-
};
|
|
454
441
|
try {
|
|
442
|
+
const contents = await removeDefaultExport(filepath);
|
|
443
|
+
const buildOptions = {
|
|
444
|
+
...standardBuildOptions,
|
|
445
|
+
minify: false,
|
|
446
|
+
write: false,
|
|
447
|
+
legalComments: "none"
|
|
448
|
+
};
|
|
449
|
+
buildOptions.stdin = {
|
|
450
|
+
sourcefile: filepath,
|
|
451
|
+
contents,
|
|
452
|
+
loader: filepath.endsWith(".ts") ? "ts" : filepath.endsWith(".tsx") ? "tsx" : filepath.endsWith(".js") ? "js" : filepath.endsWith(".jsx") ? "jsx" : "default",
|
|
453
|
+
resolveDir: dirname(filepath)
|
|
454
|
+
};
|
|
455
455
|
const output = await build(buildOptions);
|
|
456
456
|
const bundle = new TextDecoder().decode((_a = output.outputFiles[0]) == null ? void 0 : _a.contents);
|
|
457
457
|
return vercelEndpointExports.parse(_eval(bundle, filepath, {}, true));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-vercel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"vike": "*",
|
|
24
24
|
"vite": "^4.2.0",
|
|
25
|
-
"@vite-plugin-vercel/vike": "
|
|
25
|
+
"@vite-plugin-vercel/vike": "3.0.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependenciesMeta": {
|
|
28
28
|
"@vite-plugin-vercel/vike": {
|
|
@@ -33,24 +33,24 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^16.18.
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
38
|
-
"@typescript-eslint/parser": "^6.
|
|
39
|
-
"eslint": "^8.
|
|
40
|
-
"tsup": "^
|
|
41
|
-
"typescript": "^5.
|
|
42
|
-
"vike": "^0.4.
|
|
43
|
-
"vite": "^
|
|
44
|
-
"@vite-plugin-vercel/vike": "
|
|
36
|
+
"@types/node": "^16.18.71",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
38
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
39
|
+
"eslint": "^8.56.0",
|
|
40
|
+
"tsup": "^8.0.1",
|
|
41
|
+
"typescript": "^5.3.3",
|
|
42
|
+
"vike": "^0.4.157",
|
|
43
|
+
"vite": "^5.0.11",
|
|
44
|
+
"@vite-plugin-vercel/vike": "3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@brillout/libassert": "^0.5.8",
|
|
48
|
-
"@vercel/build-utils": "^7.
|
|
49
|
-
"@vercel/routing-utils": "^3.
|
|
50
|
-
"esbuild": "^0.19.
|
|
48
|
+
"@vercel/build-utils": "^7.5.0",
|
|
49
|
+
"@vercel/routing-utils": "^3.1.0",
|
|
50
|
+
"esbuild": "^0.19.11",
|
|
51
51
|
"eval": "^0.1.8",
|
|
52
|
-
"fast-glob": "^3.3.
|
|
53
|
-
"magicast": "^0.3.
|
|
52
|
+
"fast-glob": "^3.3.2",
|
|
53
|
+
"magicast": "^0.3.3",
|
|
54
54
|
"zod": "^3.22.4"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|