vite-plugin-vercel 11.0.0-beta.12 → 11.0.0-beta.13

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/api.js CHANGED
@@ -1,3 +1,65 @@
1
- import { n as getVercelAPI, t as createAPI } from "./api-DR2y7JVQ.js";
1
+ import { t as assert } from "./assert-vtiLgQIb.js";
2
2
 
3
+ //#region src/api.ts
4
+ function createAPI(outfiles, pluginConfig) {
5
+ return {
6
+ getOutFiles() {
7
+ return outfiles;
8
+ },
9
+ get config() {
10
+ pluginConfig.config ??= {};
11
+ return pluginConfig.config;
12
+ },
13
+ get defaultMaxDuration() {
14
+ return pluginConfig.defaultMaxDuration;
15
+ },
16
+ set defaultMaxDuration(value) {
17
+ pluginConfig.defaultMaxDuration = value;
18
+ },
19
+ get expiration() {
20
+ return pluginConfig.expiration;
21
+ },
22
+ set expiration(value) {
23
+ pluginConfig.expiration = value;
24
+ },
25
+ get rewrites() {
26
+ pluginConfig.rewrites ??= [];
27
+ return pluginConfig.rewrites;
28
+ },
29
+ get headers() {
30
+ pluginConfig.headers ??= [];
31
+ return pluginConfig.headers;
32
+ },
33
+ get redirects() {
34
+ pluginConfig.redirects ??= [];
35
+ return pluginConfig.redirects;
36
+ },
37
+ get cleanUrls() {
38
+ return pluginConfig.cleanUrls;
39
+ },
40
+ set cleanUrls(value) {
41
+ pluginConfig.cleanUrls = value;
42
+ },
43
+ get trailingSlash() {
44
+ return pluginConfig.trailingSlash;
45
+ },
46
+ set trailingSlash(value) {
47
+ pluginConfig.trailingSlash = value;
48
+ },
49
+ get defaultSupportsResponseStreaming() {
50
+ return pluginConfig.defaultSupportsResponseStreaming;
51
+ },
52
+ set defaultSupportsResponseStreaming(value) {
53
+ pluginConfig.defaultSupportsResponseStreaming = value;
54
+ }
55
+ };
56
+ }
57
+ function getVercelAPI(pluginContextOrServer) {
58
+ const vpv = ("environment" in pluginContextOrServer ? pluginContextOrServer.environment.config : pluginContextOrServer.config).plugins.find((p) => p.name === "vite-plugin-vercel:api");
59
+ assert(vpv, "Could not find vite-plugin-vercel:api plugin");
60
+ assert(vpv.api, "Missing `api`. Make sure vite-plugin-vercel is up-to-date");
61
+ return vpv.api("environment" in pluginContextOrServer ? pluginContextOrServer : void 0);
62
+ }
63
+
64
+ //#endregion
3
65
  export { createAPI, getVercelAPI };
@@ -0,0 +1,8 @@
1
+ //#region src/utils/assert.ts
2
+ function assert(condition, errorMessage) {
3
+ if (condition) return;
4
+ throw new Error(`[vite-plugin-vercel] ${errorMessage}`);
5
+ }
6
+
7
+ //#endregion
8
+ export { assert as t };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as pathRelativeTo } from "./path-B4ThGm96.js";
1
+ import { t as pathRelativeTo } from "./path-DoLvGKnz.js";
2
2
  import path from "node:path";
3
3
  import { vercelEndpointExports } from "@vite-plugin-vercel/schemas";
4
4
  import { fromNextFs } from "convert-route/next-fs";
package/dist/vite.js CHANGED
@@ -1,5 +1,6 @@
1
- import { t as pathRelativeTo$1 } from "./path-B4ThGm96.js";
2
- import { n as getVercelAPI, r as assert, t as createAPI } from "./api-DR2y7JVQ.js";
1
+ import { t as pathRelativeTo$1 } from "./path-DoLvGKnz.js";
2
+ import { t as assert } from "./assert-vtiLgQIb.js";
3
+ import { createAPI, getVercelAPI } from "./api.js";
3
4
  import { builtinModules } from "node:module";
4
5
  import path from "node:path";
5
6
  import { vercelOutputConfigSchema, vercelOutputPrerenderConfigSchema, vercelOutputVcConfigSchema } from "@vite-plugin-vercel/schemas";
@@ -115,23 +116,23 @@ function removeExtension$1(subject) {
115
116
  //#endregion
116
117
  //#region src/utils/destination.ts
117
118
  function parseViteId(id) {
118
- const [path$1, query] = id.split("?");
119
+ const [path, query] = id.split("?");
119
120
  return {
120
- path: decodeURIComponent(path$1),
121
+ path: decodeURIComponent(path),
121
122
  query
122
123
  };
123
124
  }
124
- function extractBestPath({ path: path$1, query }) {
125
- if (!query) return path$1;
126
- return query.split("&").map(decodeURIComponent).find((p) => p.includes("/")) || path$1;
125
+ function extractBestPath({ path, query }) {
126
+ if (!query) return path;
127
+ return query.split("&").map(decodeURIComponent).find((p) => p.includes("/")) || path;
127
128
  }
128
- function shortenPath(path$1, maxSegments = 2) {
129
- return removeExtension$1(path$1.split(/[\\/]/).filter(Boolean).slice(-maxSegments).join("_"));
129
+ function shortenPath(path, maxSegments = 2) {
130
+ return removeExtension$1(path.split(/[\\/]/).filter(Boolean).slice(-maxSegments).join("_"));
130
131
  }
131
- function mapPath(path$1, maxSegments = 2) {
132
- const nodeModuleMatch = path$1.match(/node_modules[\\/](.+?)([\\/].*)?$/);
132
+ function mapPath(path, maxSegments = 2) {
133
+ const nodeModuleMatch = path.match(/node_modules[\\/](.+?)([\\/].*)?$/);
133
134
  if (nodeModuleMatch) return `${nodeModuleMatch[1].split(/[\\/]/)[0]}_${removeExtension$1(nodeModuleMatch[2]?.split(/[\\/]/).pop() || "index")}`;
134
- return shortenPath(path$1, maxSegments);
135
+ return shortenPath(path, maxSegments);
135
136
  }
136
137
  function hashString(str, length = 6) {
137
138
  let hash = 5381;
@@ -162,10 +163,10 @@ function apiPlugin(pluginConfig) {
162
163
  applyToEnvironment({ name }) {
163
164
  return name === envNames.edge || name === envNames.node;
164
165
  },
165
- writeBundle(_opts, bundle$2) {
166
+ writeBundle(_opts, bundle) {
166
167
  const root = this.environment.config.root ?? process.cwd();
167
168
  const entryMapByDestination = new Map(dedupeRoutes().map((e) => [entryDestination(root, e, ".func/index"), e]));
168
- for (const [key, value] of Object.entries(bundle$2)) if (value.type === "chunk" && entryMapByDestination.has(removeExtension$1(key))) outfiles.push({
169
+ for (const [key, value] of Object.entries(bundle)) if (value.type === "chunk" && entryMapByDestination.has(removeExtension$1(key))) outfiles.push({
169
170
  type: "chunk",
170
171
  root: this.environment.config.root,
171
172
  outdir: this.environment.config.build.outDir,
@@ -246,8 +247,8 @@ function basicBundlePlugin(pluginConfig) {
246
247
  name: "vite-plugin-vercel:bundle",
247
248
  enforce: "post",
248
249
  apply: "build",
249
- generateBundle(_opts, bundle$2) {
250
- for (const b of Object.values(bundle$2)) {
250
+ generateBundle(_opts, bundle) {
251
+ for (const b of Object.values(bundle)) {
251
252
  const outFile = joinAbsolute(this.environment, this.environment.config.build.outDir, b.fileName);
252
253
  if (b.type === "asset") {
253
254
  const originalFileNames = b.originalFileNames.map((relativePath) => path.resolve(this.environment.config.root, relativePath));
@@ -292,7 +293,7 @@ async function bundle$1(pluginContext, bundledAssets, outfile) {
292
293
  buildOptions.output = {
293
294
  format: "esm",
294
295
  legalComments: "none",
295
- inlineDynamicImports: true
296
+ codeSplitting: false
296
297
  };
297
298
  buildOptions.checks = { pluginTimings: false };
298
299
  buildOptions.input = [source];
@@ -312,13 +313,6 @@ async function bundle$1(pluginContext, bundledAssets, outfile) {
312
313
  } else {
313
314
  buildOptions.platform = "node";
314
315
  buildOptions.output.file = destination.replace(/\.js$/, ".mjs");
315
- buildOptions.output.banner = `import { createRequire as topLevelCreateRequire } from 'node:module';
316
- import { dirname as topLevelDirname } from 'node:path';
317
- import { fileURLToPath as topLevelFileURLToPath } from 'node:url';
318
- var require = topLevelCreateRequire(import.meta.url);
319
- var __filename = topLevelFileURLToPath(import.meta.url);
320
- var __dirname = topLevelDirname(__filename);
321
- `;
322
316
  }
323
317
  try {
324
318
  await build(buildOptions);
@@ -417,15 +411,15 @@ function nf3BundlePlugin(pluginConfig) {
417
411
  async writeBundle(_, output) {
418
412
  const isEdge = this.environment.name === envNames.edge;
419
413
  const config = this.environment.config;
420
- const outDir$1 = normalizePath(path.isAbsolute(config.build.outDir) ? config.build.outDir : path.join(config.root, config.build.outDir));
414
+ const outDir = normalizePath(path.isAbsolute(config.build.outDir) ? config.build.outDir : path.join(config.root, config.build.outDir));
421
415
  const entries = Object.entries(output).filter((e) => "isEntry" in e[1] && e[1].isEntry).map((e) => ({
422
416
  name: e[1].name,
423
417
  fileName: e[1].fileName,
424
- outPath: path.join(outDir$1, e[1].fileName)
418
+ outPath: path.join(outDir, e[1].fileName)
425
419
  }));
426
420
  if (entries.length === 0) return;
427
421
  const outPaths = entries.map((entry) => entry.outPath);
428
- const input = Object.fromEntries(outPaths.map((e) => [removeExtension(pathRelativeTo(e, outDir$1)), e]));
422
+ const input = Object.fromEntries(outPaths.map((e) => [removeExtension(pathRelativeTo(e, outDir)), e]));
429
423
  const limit = pLimit(Math.max(1, Math.ceil(cpus().length / 2)));
430
424
  const nonVitePlugins = this.environment.config.plugins.filter((p) => {
431
425
  return !p.name.startsWith("vite:") && p.name !== "alias" && p.name !== "commonjs" && p.name !== "nitro:externals";
@@ -434,12 +428,12 @@ function nf3BundlePlugin(pluginConfig) {
434
428
  return rest;
435
429
  });
436
430
  const localOutput = (await Promise.all(Object.values(input).map((entryPath) => limit(async () => {
437
- const outDir$2 = path.dirname(entryPath);
431
+ const outDir = path.dirname(entryPath);
438
432
  return { output: (await bundle({
439
433
  plugins: nonVitePlugins,
440
434
  isEdge,
441
435
  input: { index: entryPath },
442
- outDir: outDir$2,
436
+ outDir,
443
437
  externals: {
444
438
  conditions: this.environment.config.resolve.conditions,
445
439
  rootDir: this.environment.config.root,
@@ -452,7 +446,7 @@ function nf3BundlePlugin(pluginConfig) {
452
446
  }
453
447
  })).output.map((o) => ({
454
448
  ...o,
455
- fileName: path.join(outDir$2, o.fileName)
449
+ fileName: path.join(outDir, o.fileName)
456
450
  })) };
457
451
  })))).flatMap((r) => r.output);
458
452
  buildOutput = buildOutput ? [...buildOutput, ...localOutput] : localOutput;
@@ -551,7 +545,7 @@ function getVcConfig(pluginConfig, filename, options) {
551
545
 
552
546
  //#endregion
553
547
  //#region src/plugins/loader.ts
554
- const re_DUMMY = /* @__PURE__ */ new RegExp(`__DUMMY__$`);
548
+ const re_DUMMY = new RegExp(`__DUMMY__$`);
555
549
  const re_edge = /[?&]vercel_edge\b/;
556
550
  const re_node = /[?&]vercel_node\b/;
557
551
  function loaderPlugin(pluginConfig) {
@@ -844,8 +838,8 @@ function setupEnvs(pluginConfig) {
844
838
  },
845
839
  generateBundle: {
846
840
  order: "post",
847
- async handler(_opts, bundle$2) {
848
- cleanupDummy(bundle$2);
841
+ async handler(_opts, bundle) {
842
+ cleanupDummy(bundle);
849
843
  }
850
844
  },
851
845
  sharedDuringBuild: true
@@ -861,8 +855,8 @@ function setupEnvs(pluginConfig) {
861
855
  },
862
856
  generateBundle: {
863
857
  order: "post",
864
- async handler(_opts, bundle$2) {
865
- cleanupDummy(bundle$2);
858
+ async handler(_opts, bundle) {
859
+ cleanupDummy(bundle);
866
860
  this.emitFile({
867
861
  type: "asset",
868
862
  fileName: "config.json",
@@ -877,8 +871,8 @@ function setupEnvs(pluginConfig) {
877
871
  applyToEnvironment(env) {
878
872
  return env.name === envNames.client;
879
873
  },
880
- generateBundle: { async handler(_opts, bundle$2) {
881
- cleanupDummy(bundle$2);
874
+ generateBundle: { async handler(_opts, bundle) {
875
+ cleanupDummy(bundle);
882
876
  const topLevelConfig = this.environment.getTopLevelConfig();
883
877
  const clientEnv = topLevelConfig.environments.client;
884
878
  if (clientEnv) try {
@@ -926,9 +920,9 @@ function createVercelEnvironmentOptions(overrides) {
926
920
  function getDummyInput() {
927
921
  return { [DUMMY]: `${virtualEntry}:${DUMMY}` };
928
922
  }
929
- function cleanupDummy(bundle$2) {
930
- const dummy = Object.keys(bundle$2).find((key) => key.includes("_DUMMY_"));
931
- if (dummy) delete bundle$2[dummy];
923
+ function cleanupDummy(bundle) {
924
+ const dummy = Object.keys(bundle).find((key) => key.includes("_DUMMY_"));
925
+ if (dummy) delete bundle[dummy];
932
926
  }
933
927
 
934
928
  //#endregion
@@ -945,7 +939,6 @@ function vercel(pluginConfig = {}) {
945
939
  devServer()
946
940
  ];
947
941
  }
948
- var plugins_default = vercel;
949
942
 
950
943
  //#endregion
951
- export { plugins_default as default, vercel };
944
+ export { vercel as default, vercel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vercel",
3
- "version": "11.0.0-beta.12",
3
+ "version": "11.0.0-beta.13",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -26,7 +26,7 @@
26
26
  "@types/node": "^22.19.3",
27
27
  "@universal-middleware/express": "^0.4.22",
28
28
  "@vercel/node": "^5.5.15",
29
- "tsdown": "^0.18.4",
29
+ "tsdown": "^0.20.3",
30
30
  "typescript": "^5.9.3",
31
31
  "vite": "^7.2.4",
32
32
  "vitest": "^4.0.16"
@@ -46,7 +46,7 @@
46
46
  "oxc-transform": "^0.108.0",
47
47
  "p-limit": "^7.2.0",
48
48
  "path-to-regexp": "^8.3.0",
49
- "rolldown": "^1.0.0-beta.58",
49
+ "rolldown": "^1.0.0-rc.4",
50
50
  "strip-ansi": "^7.1.2",
51
51
  "vite-plugin-wasm": "^3.5.0",
52
52
  "@vite-plugin-vercel/schemas": "^1.0.0"
@@ -1,70 +0,0 @@
1
- //#region src/utils/assert.ts
2
- function assert(condition, errorMessage) {
3
- if (condition) return;
4
- throw new Error(`[vite-plugin-vercel] ${errorMessage}`);
5
- }
6
-
7
- //#endregion
8
- //#region src/api.ts
9
- function createAPI(outfiles, pluginConfig) {
10
- return {
11
- getOutFiles() {
12
- return outfiles;
13
- },
14
- get config() {
15
- pluginConfig.config ??= {};
16
- return pluginConfig.config;
17
- },
18
- get defaultMaxDuration() {
19
- return pluginConfig.defaultMaxDuration;
20
- },
21
- set defaultMaxDuration(value) {
22
- pluginConfig.defaultMaxDuration = value;
23
- },
24
- get expiration() {
25
- return pluginConfig.expiration;
26
- },
27
- set expiration(value) {
28
- pluginConfig.expiration = value;
29
- },
30
- get rewrites() {
31
- pluginConfig.rewrites ??= [];
32
- return pluginConfig.rewrites;
33
- },
34
- get headers() {
35
- pluginConfig.headers ??= [];
36
- return pluginConfig.headers;
37
- },
38
- get redirects() {
39
- pluginConfig.redirects ??= [];
40
- return pluginConfig.redirects;
41
- },
42
- get cleanUrls() {
43
- return pluginConfig.cleanUrls;
44
- },
45
- set cleanUrls(value) {
46
- pluginConfig.cleanUrls = value;
47
- },
48
- get trailingSlash() {
49
- return pluginConfig.trailingSlash;
50
- },
51
- set trailingSlash(value) {
52
- pluginConfig.trailingSlash = value;
53
- },
54
- get defaultSupportsResponseStreaming() {
55
- return pluginConfig.defaultSupportsResponseStreaming;
56
- },
57
- set defaultSupportsResponseStreaming(value) {
58
- pluginConfig.defaultSupportsResponseStreaming = value;
59
- }
60
- };
61
- }
62
- function getVercelAPI(pluginContextOrServer) {
63
- const vpv = ("environment" in pluginContextOrServer ? pluginContextOrServer.environment.config : pluginContextOrServer.config).plugins.find((p) => p.name === "vite-plugin-vercel:api");
64
- assert(vpv, "Could not find vite-plugin-vercel:api plugin");
65
- assert(vpv.api, "Missing `api`. Make sure vite-plugin-vercel is up-to-date");
66
- return vpv.api("environment" in pluginContextOrServer ? pluginContextOrServer : void 0);
67
- }
68
-
69
- //#endregion
70
- export { getVercelAPI as n, assert as r, createAPI as t };
File without changes