vite-plugin-vercel 0.1.0 → 0.1.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 CHANGED
@@ -2,9 +2,29 @@
2
2
 
3
3
  This is a **Work In Progress** Vercel adapter for [`vite`](https://vitejs.dev/).
4
4
 
5
+ Its purpose is to help you bundle your application in `.vercel` folder as supported by
6
+ ([Vercel API v3](https://vercel.com/docs/build-output-api/v3)).
7
+
8
+ ## Features
9
+
10
+ - [x] [SSG/Static files support](https://vercel.com/docs/build-output-api/v3#vercel-primitives/static-files)
11
+ - see [`prerender` config](/packages/vercel/src/types.ts#L33)
12
+ - [x] [SSR/Serverless functions support](https://vercel.com/docs/build-output-api/v3#vercel-primitives/serverless-functions)
13
+ - `.[jt]s` files under the `<root>/api` folder of your project are automatically bundled as Serverless functions under `.vercel/output/functions/api/*.func`
14
+ - see [`additionalEndpoints` config](/packages/vercel/src/types.ts#L54)
15
+ - [x] [ISR/Prerender functions support](https://vercel.com/docs/build-output-api/v3#vercel-primitives/prerender-functions)
16
+ - see [`isr` config](/packages/vercel/src/types.ts#L81). Also see implementation of [vite-plugin-ssr](./prerender/vite-plugin-ssr.ts) for example
17
+ - [ ] [Edge functions support](https://vercel.com/docs/build-output-api/v3#vercel-primitives/edge-functions)
18
+ - [ ] [Images optimization support](https://vercel.com/docs/build-output-api/v3#build-output-configuration/supported-properties/images)
19
+ - [ ] [Preview mode support](https://vercel.com/docs/build-output-api/v3#features/preview-mode)
20
+ - [x] [Advanced config override](/packages/vercel/src/types.ts#L15)
21
+ - [ ] Complete config override
22
+
5
23
  ## Usage
6
24
 
7
- Install as a dev dependency and add it to your Vite config like this:
25
+ First, make sure `ENABLE_VC_BUILD=1` is declared as an Environment Variable in your deployment configuration.
26
+
27
+ Then, install this package as a dev dependency and add it to your Vite config like this:
8
28
 
9
29
  ```ts
10
30
  import { defineConfig } from 'vite';
@@ -21,30 +41,18 @@ export default defineConfig({
21
41
  [vite-plugin-ssr](https://vite-plugin-ssr.com/) will support this plugin when stable.
22
42
  In the meantime, you can add experimental support yourself.
23
43
 
24
- First copy [prerender](../../prerender) folder to the root of your project.
25
- Then, update your vercel config:
44
+ Install `@magne4000/vite-plugin-vercel-ssr` package, and update your vite config:
26
45
 
27
46
  ```ts
28
- // vercel.config.ts
29
- // A TS config is prefered if your project is of { type: "module" }
30
-
31
- import module from 'module';
47
+ // vite.config.ts
32
48
  import { defineConfig } from 'vite';
33
49
  import ssr from 'vite-plugin-ssr/plugin';
34
50
  import vercel from 'vite-plugin-vercel';
35
-
36
- // FIX esbuild bug https://github.com/evanw/esbuild/pull/2067
37
- // probably not necessary when `./prerender/vite-plugin-ssr` will be included in `vite-plugin-ssr`
38
- // eslint-disable-next-line no-undef
39
- globalThis.require = module.createRequire(import.meta.url);
51
+ import vercelSsr from '@magne4000/vite-plugin-vercel-ssr';
40
52
 
41
53
  export default defineConfig(async ({ command, mode }) => {
42
- // Dynamic import to bypass esbuild compilation issue.
43
- // If you are not using ESM, could me move as a top synchronous import
44
- const vitePluginSsrVercelPlugin = await import('./prerender/vite-plugin-ssr');
45
-
46
54
  return {
47
- plugins: [ssr(), vercel(), vitePluginSsrVercelPlugin.default()],
55
+ plugins: [ssr(), vercel(), vercelSsr()],
48
56
  build: {
49
57
  polyfillDynamicImport: false,
50
58
  },
@@ -54,3 +62,11 @@ export default defineConfig(async ({ command, mode }) => {
54
62
  };
55
63
  });
56
64
  ```
65
+
66
+ ### Config
67
+
68
+ See [TS types](/packages/vercel/src/types.ts#L15) for details.
69
+
70
+ ## Demo
71
+
72
+ https://test-vite-vercel-plugin.vercel.app/
package/dist/index.cjs CHANGED
@@ -254,7 +254,7 @@ function getEntries(resolvedConfig) {
254
254
  const parsed = import_path3.default.parse(outFilePath);
255
255
  const entry = {
256
256
  source: filePath,
257
- destination: `api/${import_path3.default.join(parsed.dir, parsed.name)}.func`
257
+ destination: `api/${import_path3.default.posix.join(parsed.dir, parsed.name)}.func`
258
258
  };
259
259
  entryPoints.push(entry);
260
260
  return entryPoints;
package/dist/index.js CHANGED
@@ -231,7 +231,7 @@ function getEntries(resolvedConfig) {
231
231
  const parsed = path3.parse(outFilePath);
232
232
  const entry = {
233
233
  source: filePath,
234
- destination: `api/${path3.join(parsed.dir, parsed.name)}.func`
234
+ destination: `api/${path3.posix.join(parsed.dir, parsed.name)}.func`
235
235
  };
236
236
  entryPoints.push(entry);
237
237
  return entryPoints;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vercel",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -23,20 +23,20 @@
23
23
  "vite": "^2.9.9"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "^17.0.34",
27
- "@typescript-eslint/eslint-plugin": "^5.24.0",
28
- "@typescript-eslint/parser": "^5.24.0",
29
- "eslint": "^8.15.0",
30
- "eslint-plugin-solid": "^0.4.7",
31
- "tsup": "^5.12.8",
32
- "typescript": "^4.6.4"
26
+ "@types/node": "^17.0.36",
27
+ "@typescript-eslint/eslint-plugin": "^5.26.0",
28
+ "@typescript-eslint/parser": "^5.26.0",
29
+ "eslint": "^8.16.0",
30
+ "tsup": "^6.0.1",
31
+ "typescript": "^4.7.2",
32
+ "vite": "^2.9.9"
33
33
  },
34
34
  "dependencies": {
35
35
  "@brillout/libassert": "^0.5.6",
36
- "@vercel/routing-utils": "^1.13.2",
37
- "esbuild": "^0.14.39",
36
+ "@vercel/routing-utils": "^1.13.3",
37
+ "esbuild": "^0.14.42",
38
38
  "fast-glob": "^3.2.11",
39
- "zod": "^3.16.0"
39
+ "zod": "^3.17.3"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsup",