vercel 54.18.6 → 54.19.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.
Files changed (72) hide show
  1. package/dist/chunks/{add-DFHK2LCD.js → add-P6CBTAGK.js} +4 -4
  2. package/dist/chunks/add-WB6SXGXX.js +134 -0
  3. package/dist/chunks/{chunk-LQALVXRD.js → chunk-3S2QGKYZ.js} +1 -1
  4. package/dist/chunks/chunk-4QVAYRYH.js +71 -0
  5. package/dist/chunks/{chunk-22CQWS5E.js → chunk-5MVXR7B7.js} +1 -1
  6. package/dist/chunks/{chunk-VKGCONIM.js → chunk-6ISLGUMI.js} +3 -3
  7. package/dist/chunks/chunk-AUECDTMX.js +128 -0
  8. package/dist/chunks/{chunk-3WENOEKR.js → chunk-FM24W7ET.js} +4 -4
  9. package/dist/chunks/{chunk-GXAVQSHO.js → chunk-FVI6UYNL.js} +1 -1
  10. package/dist/chunks/{chunk-DHLDURNP.js → chunk-FZZWTDNQ.js} +2 -2
  11. package/dist/chunks/chunk-I3HGCZ4E.js +72 -0
  12. package/dist/chunks/{chunk-CXGDCPH4.js → chunk-ITU4COOO.js} +12 -3
  13. package/dist/chunks/chunk-KXGWAWRV.js +148 -0
  14. package/dist/chunks/{chunk-NN7E6Y4F.js → chunk-L6QLQSJE.js} +2 -2
  15. package/dist/chunks/{chunk-XQQXV6ZZ.js → chunk-LFODAB54.js} +1 -0
  16. package/dist/chunks/{chunk-I43WUYKE.js → chunk-O2QNLUYX.js} +1 -1
  17. package/dist/chunks/{chunk-BI2IN6RX.js → chunk-P726GMBL.js} +1 -1
  18. package/dist/chunks/{chunk-7273TMGI.js → chunk-Q4A2Q46Z.js} +4 -4
  19. package/dist/chunks/{chunk-ODVBO56J.js → chunk-Q7GZMMHB.js} +2 -2
  20. package/dist/chunks/{chunk-F6YGVA2L.js → chunk-RB7WQKNC.js} +3 -2
  21. package/dist/chunks/{chunk-URFSONFS.js → chunk-RKLBPBRM.js} +1 -1
  22. package/dist/chunks/chunk-RY3AVR6E.js +111 -0
  23. package/dist/chunks/{chunk-QPBO2QDL.js → chunk-SQYJEUZD.js} +4 -4
  24. package/dist/chunks/{chunk-ZAJ4OMXG.js → chunk-TV7GKFSY.js} +1 -1
  25. package/dist/chunks/{chunk-PPW2JATF.js → chunk-U3FBUYRS.js} +1 -1
  26. package/dist/chunks/chunk-VGIMO3ZK.js +17 -0
  27. package/dist/chunks/{chunk-BSSEGYXP.js → chunk-WFXGLPSI.js} +7 -3
  28. package/dist/chunks/{chunk-V7IBBQ2D.js → chunk-YWLVPKNT.js} +1 -1
  29. package/dist/chunks/chunk-ZVDYGXRA.js +363 -0
  30. package/dist/chunks/{chunk-VTE7W5ZP.js → chunk-ZZIAWRCX.js} +0 -8
  31. package/dist/chunks/{compile-vercel-config-WRCB2TG2.js → compile-vercel-config-XEZ2TPQ4.js} +1 -1
  32. package/dist/chunks/{delete-DIFVXSQA.js → delete-O3F4EP2W.js} +2 -2
  33. package/dist/chunks/{disable-623SZAWT.js → disable-SJWGUQKZ.js} +2 -2
  34. package/dist/chunks/{discard-R7YAQI6C.js → discard-EQD6ENC3.js} +2 -2
  35. package/dist/chunks/{edit-CY2RYSKD.js → edit-NAIWNSXE.js} +3 -3
  36. package/dist/chunks/{enable-HHOQLDPW.js → enable-LXO62HU5.js} +2 -2
  37. package/dist/chunks/{export-TNFZHJKM.js → export-EHVTYAAP.js} +2 -2
  38. package/dist/chunks/image-R4JG4NX4.js +73 -0
  39. package/dist/chunks/inspect-57BITHYZ.js +136 -0
  40. package/dist/chunks/{inspect-7JLYYYAR.js → inspect-KYVZQL56.js} +3 -3
  41. package/dist/chunks/inspect-RTJALSXC.js +167 -0
  42. package/dist/chunks/inspect-VXODLWNM.js +163 -0
  43. package/dist/chunks/{list-5LKLQBXP.js → list-BYTNF7D7.js} +3 -3
  44. package/dist/chunks/{list-K4F7WGQR.js → list-MUFZTUZA.js} +2 -2
  45. package/dist/chunks/ls-D7NWJACX.js +165 -0
  46. package/dist/chunks/ls-JPWOOVMW.js +214 -0
  47. package/dist/chunks/{ls-DUHNXBAL.js → ls-PDILBRUL.js} +4 -4
  48. package/dist/chunks/ls-ZDMXBOJF.js +201 -0
  49. package/dist/chunks/{publish-O5UJJQKF.js → publish-27V2MMFS.js} +2 -2
  50. package/dist/chunks/{query-FE6G54EI.js → query-75PT24SH.js} +2 -2
  51. package/dist/chunks/{reorder-YH47SCZC.js → reorder-DCSIJX72.js} +2 -2
  52. package/dist/chunks/{restore-TSR6PO3H.js → restore-NRUBGNSK.js} +2 -2
  53. package/dist/chunks/{rm-PQSDPXP2.js → rm-BJSTNUIJ.js} +4 -4
  54. package/dist/chunks/rm-OSIDD4VR.js +137 -0
  55. package/dist/chunks/rm-ZJQ5DOAW.js +137 -0
  56. package/dist/chunks/{rule-inspect-TNP2HULT.js → rule-inspect-WTU3MGMH.js} +4 -4
  57. package/dist/chunks/{rules-IO4KI6U7.js → rules-6PXGKHFH.js} +6 -6
  58. package/dist/chunks/{schema-QFN4XSPZ.js → schema-Z6L3EN6F.js} +2 -2
  59. package/dist/chunks/tags-HHNNZLC6.js +67 -0
  60. package/dist/chunks/{update-PGYIRCOQ.js → update-TTPNV44H.js} +4 -4
  61. package/dist/commands/build/index.js +148 -50
  62. package/dist/commands/deploy/index.js +13 -10
  63. package/dist/commands/dev/index.js +8 -8
  64. package/dist/commands/dev/next-dev-websocket-shim-preload.cjs +20 -0
  65. package/dist/commands/env/index.js +11 -6
  66. package/dist/commands/link/index.js +10 -7
  67. package/dist/commands/list/index.js +3 -3
  68. package/dist/commands-bulk.js +957 -723
  69. package/dist/help.js +1 -1
  70. package/dist/index.js +22 -9
  71. package/dist/version.mjs +1 -1
  72. package/package.json +15 -15
@@ -11,36 +11,36 @@ import {
11
11
  isLambda,
12
12
  staticFiles,
13
13
  writeBuildResult
14
- } from "../../chunks/chunk-CXGDCPH4.js";
14
+ } from "../../chunks/chunk-ITU4COOO.js";
15
15
  import {
16
16
  pullCommandLogic
17
- } from "../../chunks/chunk-7273TMGI.js";
17
+ } from "../../chunks/chunk-Q4A2Q46Z.js";
18
18
  import {
19
19
  require_semver
20
20
  } from "../../chunks/chunk-IB5L4LKZ.js";
21
21
  import {
22
22
  pickOverrides,
23
23
  readProjectSettings
24
- } from "../../chunks/chunk-22CQWS5E.js";
24
+ } from "../../chunks/chunk-5MVXR7B7.js";
25
25
  import "../../chunks/chunk-24FCBXI4.js";
26
26
  import "../../chunks/chunk-NJUPUGOE.js";
27
27
  import {
28
28
  stamp_default
29
29
  } from "../../chunks/chunk-64IF634X.js";
30
30
  import "../../chunks/chunk-VXYGCOKL.js";
31
- import "../../chunks/chunk-ODVBO56J.js";
31
+ import "../../chunks/chunk-Q7GZMMHB.js";
32
32
  import {
33
33
  printProjectNotFoundError
34
- } from "../../chunks/chunk-VKGCONIM.js";
34
+ } from "../../chunks/chunk-6ISLGUMI.js";
35
35
  import {
36
36
  AGENT_REASON,
37
37
  AGENT_STATUS
38
38
  } from "../../chunks/chunk-QH7WYDEP.js";
39
- import "../../chunks/chunk-V7IBBQ2D.js";
39
+ import "../../chunks/chunk-YWLVPKNT.js";
40
40
  import {
41
41
  buildCommand
42
- } from "../../chunks/chunk-I43WUYKE.js";
43
- import "../../chunks/chunk-BI2IN6RX.js";
42
+ } from "../../chunks/chunk-O2QNLUYX.js";
43
+ import "../../chunks/chunk-P726GMBL.js";
44
44
  import {
45
45
  help
46
46
  } from "../../chunks/chunk-YSIZGIDP.js";
@@ -50,6 +50,7 @@ import {
50
50
  VERCEL_DIR,
51
51
  compileVercelConfig,
52
52
  findSourceVercelConfigFile,
53
+ getGitRootDirectory,
53
54
  getLinkedProject,
54
55
  getProjectLink,
55
56
  parseTarget,
@@ -66,7 +67,7 @@ import {
66
67
  resolveProjectCwd,
67
68
  ua_default,
68
69
  validateConfig
69
- } from "../../chunks/chunk-F6YGVA2L.js";
70
+ } from "../../chunks/chunk-RB7WQKNC.js";
70
71
  import {
71
72
  outputAgentError
72
73
  } from "../../chunks/chunk-IZOHLD5D.js";
@@ -115,7 +116,7 @@ var import_client = __toESM(require_dist(), 1);
115
116
  var import_frameworks2 = __toESM(require_frameworks(), 1);
116
117
  var import_fs_detectors2 = __toESM(require_dist3(), 1);
117
118
  var import_routing_utils2 = __toESM(require_dist2(), 1);
118
- import { dirname, join as join3, normalize, relative as relative2, resolve, sep } from "path";
119
+ import { dirname as dirname2, join as join4, normalize, relative as relative3, resolve, sep } from "path";
119
120
  import { readdirSync, statSync } from "fs";
120
121
  import {
121
122
  download,
@@ -458,8 +459,85 @@ async function shouldEmbedFlagsDefinitions(cwd) {
458
459
  return false;
459
460
  }
460
461
 
462
+ // src/util/build/repo-root.ts
463
+ import { existsSync, readFileSync } from "fs";
464
+ import { dirname, join as join2, parse, relative as relative2 } from "path";
465
+ function resolveRepoRoot({ cwd }) {
466
+ const workspaceRoot = findWorkspaceRoot(cwd);
467
+ if (workspaceRoot) {
468
+ return workspaceRoot;
469
+ }
470
+ const gitRoot = getGitRootDirectory({ cwd });
471
+ if (gitRoot) {
472
+ return gitRoot;
473
+ }
474
+ return cwd;
475
+ }
476
+ function findWorkspaceRoot(startDir) {
477
+ const { root } = parse(startDir);
478
+ let dir = startDir;
479
+ let highestMatch = null;
480
+ for (let i = 0; i < 64; i++) {
481
+ if (isWorkspaceRoot(dir)) {
482
+ highestMatch = dir;
483
+ }
484
+ if (dir === root)
485
+ break;
486
+ const parent = dirname(dir);
487
+ if (parent === dir)
488
+ break;
489
+ dir = parent;
490
+ }
491
+ return highestMatch;
492
+ }
493
+ function isWorkspaceRoot(dir) {
494
+ if (existsSync(join2(dir, "pnpm-workspace.yaml")) || existsSync(join2(dir, "lerna.json")) || existsSync(join2(dir, "rush.json"))) {
495
+ return true;
496
+ }
497
+ const pkgPath = join2(dir, "package.json");
498
+ if (existsSync(pkgPath)) {
499
+ try {
500
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
501
+ const { workspaces } = pkg;
502
+ if (Array.isArray(workspaces) && workspaces.length > 0 || workspaces && typeof workspaces === "object" && Array.isArray(workspaces.packages) && workspaces.packages.length > 0) {
503
+ return true;
504
+ }
505
+ } catch {
506
+ }
507
+ }
508
+ return false;
509
+ }
510
+ function resolvePerDirectoryLinkRoot(anchorDir, rootDirectorySetting) {
511
+ const repoRoot = resolveRepoRoot({ cwd: anchorDir });
512
+ const linkLocation = normalizeRelative(relative2(repoRoot, anchorDir));
513
+ if (linkLocation === "") {
514
+ return { repoRoot, resolvedRootDirectory: "" };
515
+ }
516
+ const setting = normalizeRelative(rootDirectorySetting ?? "");
517
+ if (setting === "") {
518
+ return { repoRoot, resolvedRootDirectory: linkLocation };
519
+ }
520
+ if (existsSync(join2(anchorDir, setting))) {
521
+ return {
522
+ repoRoot,
523
+ resolvedRootDirectory: normalizeRelative(
524
+ relative2(repoRoot, join2(anchorDir, setting))
525
+ )
526
+ };
527
+ }
528
+ return {
529
+ repoRoot,
530
+ resolvedRootDirectory: linkLocation,
531
+ advisory: `Ignoring "rootDirectory" setting "${setting}" for the project linked in "${anchorDir}": "${join2(anchorDir, setting)}" does not exist, so the build will use the linked directory "${linkLocation}" instead. Remove the "rootDirectory" setting, or configure it at the repository root.`
532
+ };
533
+ }
534
+ function normalizeRelative(p) {
535
+ const normalized = p.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
536
+ return normalized === "." ? "" : normalized;
537
+ }
538
+
461
539
  // src/commands/build/manifest.ts
462
- import { join as join2 } from "path";
540
+ import { join as join3 } from "path";
463
541
  import {
464
542
  FileBlob,
465
543
  downloadFile,
@@ -502,7 +580,7 @@ async function writeManifests(packageManifests, diagnostics, ops, outputDir) {
502
580
  ops.push(
503
581
  downloadFile(
504
582
  projectManifestBlob,
505
- join2(outputDir, "diagnostics", "project-manifest.json")
583
+ join3(outputDir, "diagnostics", "project-manifest.json")
506
584
  ).then(
507
585
  () => void 0,
508
586
  (err) => err
@@ -518,7 +596,7 @@ async function writeManifests(packageManifests, diagnostics, ops, outputDir) {
518
596
  ops.push(
519
597
  downloadFile(
520
598
  deployManifestBlob,
521
- join2(outputDir, "diagnostics", "deploy-manifest.json")
599
+ join3(outputDir, "diagnostics", "deploy-manifest.json")
522
600
  ).then(
523
601
  () => void 0,
524
602
  (err) => err
@@ -637,11 +715,13 @@ async function main(client) {
637
715
  return 1;
638
716
  }
639
717
  }
640
- const projectRootDirectory = link?.projectRootDirectory ?? "";
718
+ const invokedCwd = cwd;
719
+ const hasRepoLevelLink = Boolean(link?.repoRoot);
720
+ let projectRootDirectory = link?.projectRootDirectory ?? "";
641
721
  if (link?.repoRoot) {
642
722
  cwd = client.cwd = link.repoRoot;
643
723
  }
644
- const vercelDir = join3(cwd, projectRootDirectory, VERCEL_DIR);
724
+ const vercelDir = join4(cwd, projectRootDirectory, VERCEL_DIR);
645
725
  let project = await rootSpan.child("vc.readProjectSettings").trace(() => readProjectSettings(vercelDir));
646
726
  const isTTY = process.stdin.isTTY;
647
727
  while (!project?.settings) {
@@ -697,7 +777,7 @@ async function main(client) {
697
777
  return 0;
698
778
  }
699
779
  const { argv: originalArgv } = client;
700
- client.cwd = join3(cwd, projectRootDirectory);
780
+ client.cwd = join4(cwd, projectRootDirectory);
701
781
  client.setArgv([
702
782
  ...originalArgv.slice(0, 2),
703
783
  "pull",
@@ -719,9 +799,23 @@ async function main(client) {
719
799
  client.setArgv(originalArgv);
720
800
  project = await readProjectSettings(vercelDir);
721
801
  }
722
- const defaultOutputDir = join3(cwd, projectRootDirectory, OUTPUT_DIR);
802
+ if (!hasRepoLevelLink && link && project?.settings && process.env.VERCEL_RESOLVE_ROOT_DIRECTORY === "1") {
803
+ const resolved = resolvePerDirectoryLinkRoot(
804
+ invokedCwd,
805
+ project.settings.rootDirectory
806
+ );
807
+ if (resolved.advisory) {
808
+ output_manager_default.warn(resolved.advisory);
809
+ }
810
+ if (resolved.resolvedRootDirectory !== "") {
811
+ projectRootDirectory = resolved.resolvedRootDirectory;
812
+ project.settings.rootDirectory = resolved.resolvedRootDirectory;
813
+ cwd = client.cwd = resolved.repoRoot;
814
+ }
815
+ }
816
+ const defaultOutputDir = join4(cwd, projectRootDirectory, OUTPUT_DIR);
723
817
  const outputDir = parsedArgs.flags["--output"] ? resolve(parsedArgs.flags["--output"]) : defaultOutputDir;
724
- client.traceDiagnosticsPath = join3(
818
+ client.traceDiagnosticsPath = join4(
725
819
  outputDir,
726
820
  "diagnostics",
727
821
  "cli_traces.json"
@@ -766,7 +860,7 @@ async function main(client) {
766
860
  `Loaded ${Object.keys(buildEnv).length} environment variables from deployment ${deploymentId}`
767
861
  );
768
862
  } else {
769
- const envPath = join3(
863
+ const envPath = join4(
770
864
  cwd,
771
865
  projectRootDirectory,
772
866
  VERCEL_DIR,
@@ -804,7 +898,7 @@ async function main(client) {
804
898
  await rootSpan.stop();
805
899
  }
806
900
  if (client.nonInteractive) {
807
- const relOutputDir = relative2(cwd, outputDir);
901
+ const relOutputDir = relative3(cwd, outputDir);
808
902
  client.stdout.write(
809
903
  `${JSON.stringify(
810
904
  {
@@ -857,8 +951,8 @@ async function main(client) {
857
951
  }
858
952
  output_manager_default.prettyError(err);
859
953
  buildsJson.error = toEnumerableError(err);
860
- const buildsJsonPath = join3(outputDir, "builds.json");
861
- const configJsonPath = join3(outputDir, "config.json");
954
+ const buildsJsonPath = join4(outputDir, "builds.json");
955
+ const configJsonPath = join4(outputDir, "config.json");
862
956
  await import_fs_extra2.default.outputJSON(buildsJsonPath, buildsJson, {
863
957
  spaces: 2
864
958
  });
@@ -875,11 +969,12 @@ async function main(client) {
875
969
  async function doBuild(client, project, buildsJson, cwd, outputDir, span, standalone = false) {
876
970
  const { localConfigPath } = client;
877
971
  const VALID_DEPLOYMENT_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
878
- const workPath = join3(cwd, project.settings.rootDirectory || ".");
972
+ const workPath = join4(cwd, project.settings.rootDirectory || ".");
973
+ const repoRootPath = cwd;
879
974
  const sourceConfigFile = await findSourceVercelConfigFile(workPath);
880
975
  let corepackShimDir;
881
976
  if (sourceConfigFile) {
882
- corepackShimDir = await initCorepack({ repoRootPath: cwd });
977
+ corepackShimDir = await initCorepack({ repoRootPath });
883
978
  const installDepsSpan = span.child("vc.installDeps");
884
979
  try {
885
980
  const installCommand = project.settings.installCommand;
@@ -911,9 +1006,9 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
911
1006
  process.env.VERCEL_INSTALL_COMPLETED = "1";
912
1007
  }
913
1008
  const compileResult = await span.child("vc.compileVercelConfig").trace(() => compileVercelConfig(workPath));
914
- const vercelConfigPath = localConfigPath || compileResult.configPath || join3(workPath, "vercel.json");
1009
+ const vercelConfigPath = localConfigPath || compileResult.configPath || join4(workPath, "vercel.json");
915
1010
  const [pkg, vercelConfig, hasInstrumentation] = await Promise.all([
916
- readJSONFile(join3(workPath, "package.json")),
1011
+ readJSONFile(join4(workPath, "package.json")),
917
1012
  readJSONFile(vercelConfigPath),
918
1013
  (0, import_fs_detectors2.detectInstrumentation)(new import_fs_detectors2.LocalFileSystemDetector(workPath))
919
1014
  ]);
@@ -958,7 +1053,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
958
1053
  });
959
1054
  }
960
1055
  const files = (await staticFiles(workPath, {})).map(
961
- (f) => normalizePath(relative2(workPath, f))
1056
+ (f) => normalizePath(relative3(workPath, f))
962
1057
  );
963
1058
  const routesResult = (0, import_routing_utils2.getTransformedRoutes)(localConfig);
964
1059
  if (routesResult.error) {
@@ -1072,7 +1167,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1072
1167
  let buildersWithPkgs = await span.child("vc.importBuilders").trace(() => importBuilders(builderSpecs, cwd, span));
1073
1168
  const filesMap = {};
1074
1169
  for (const path of files) {
1075
- const fsPath = join3(workPath, path);
1170
+ const fsPath = join4(workPath, path);
1076
1171
  const { mode } = await import_fs_extra2.default.stat(fsPath);
1077
1172
  filesMap[path] = new FileFsRef({ mode, fsPath });
1078
1173
  }
@@ -1119,7 +1214,6 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1119
1214
  const executedBuilds = [];
1120
1215
  const buildResults = /* @__PURE__ */ new Map();
1121
1216
  const overrides = [];
1122
- const repoRootPath = cwd;
1123
1217
  if (!corepackShimDir) {
1124
1218
  corepackShimDir = await initCorepack({ repoRootPath });
1125
1219
  }
@@ -1156,7 +1250,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1156
1250
  let buildFiles = filesMap;
1157
1251
  if (service && serviceWorkspace && serviceWorkspace !== ".") {
1158
1252
  const wsPrefix = serviceWorkspace + "/";
1159
- buildWorkPath = join3(workPath, serviceWorkspace);
1253
+ buildWorkPath = join4(workPath, serviceWorkspace);
1160
1254
  buildEntrypoint = build.src.startsWith(wsPrefix) ? build.src.slice(wsPrefix.length) : build.src;
1161
1255
  buildFiles = {};
1162
1256
  for (const [filePath, file] of Object.entries(filesMap)) {
@@ -1389,7 +1483,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1389
1483
  }
1390
1484
  }
1391
1485
  if ("output" in buildResult && buildResult.output && (isBackendBuilder(build) || build.use === "@vercel/python")) {
1392
- const routesJsonPath = join3(buildWorkPath, ".vercel", "routes.json");
1486
+ const routesJsonPath = join4(buildWorkPath, ".vercel", "routes.json");
1393
1487
  if ((0, import_fs_extra2.existsSync)(routesJsonPath)) {
1394
1488
  try {
1395
1489
  const routesJson = await readJSONFile(routesJsonPath);
@@ -1469,7 +1563,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1469
1563
  }
1470
1564
  let mergedBuildResult = buildResult;
1471
1565
  if ("buildOutputPath" in buildResult) {
1472
- const buildOutputConfigPath = join3(
1566
+ const buildOutputConfigPath = join4(
1473
1567
  buildResult.buildOutputPath,
1474
1568
  "config.json"
1475
1569
  );
@@ -1481,7 +1575,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1481
1575
  }
1482
1576
  if (buildOutputConfig) {
1483
1577
  if (!hasExperimentalServicesV1ConfiguredInVercelConfig && !hasExperimentalServicesV2ConfiguredInVercelConfig) {
1484
- const outputConfigPath = join3(outputDir, "config.json");
1578
+ const outputConfigPath = join4(outputDir, "config.json");
1485
1579
  const outputConfig = await readJSONFile(outputConfigPath);
1486
1580
  if (outputConfig instanceof CantParseJSONFile) {
1487
1581
  throw outputConfig;
@@ -1558,7 +1652,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1558
1652
  throw err;
1559
1653
  } finally {
1560
1654
  ops.push(
1561
- download(diagnostics, join3(outputDir, "diagnostics")).then(
1655
+ download(diagnostics, join4(outputDir, "diagnostics")).then(
1562
1656
  () => void 0,
1563
1657
  (err) => err
1564
1658
  )
@@ -1614,16 +1708,16 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1614
1708
  await runBuilders(builds);
1615
1709
  await flushOps();
1616
1710
  if (!hasExperimentalServicesV1ConfiguredInVercelConfig && !hasExperimentalServicesV2ConfiguredInVercelConfig) {
1617
- const generatedConfigPath = join3(outputDir, "config.json");
1711
+ const generatedConfigPath = join4(outputDir, "config.json");
1618
1712
  const generatedConfig = await readJSONFile(generatedConfigPath);
1619
1713
  if (generatedConfig instanceof CantParseJSONFile) {
1620
1714
  throw generatedConfig;
1621
1715
  }
1622
- const defaultGeneratedOutputDir = join3(workPath, OUTPUT_DIR);
1716
+ const defaultGeneratedOutputDir = join4(workPath, OUTPUT_DIR);
1623
1717
  const generatedConfigs = [generatedConfig];
1624
1718
  if (resolve(outputDir) !== resolve(defaultGeneratedOutputDir)) {
1625
1719
  const defaultGeneratedConfig = await readJSONFile(
1626
- join3(defaultGeneratedOutputDir, "config.json")
1720
+ join4(defaultGeneratedOutputDir, "config.json")
1627
1721
  );
1628
1722
  if (defaultGeneratedConfig instanceof CantParseJSONFile) {
1629
1723
  throw defaultGeneratedConfig;
@@ -1758,7 +1852,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1758
1852
  if (needBuildsJsonOverride) {
1759
1853
  await writeBuildJson(buildsJson, outputDir);
1760
1854
  }
1761
- const configPath = join3(outputDir, "config.json");
1855
+ const configPath = join4(outputDir, "config.json");
1762
1856
  const existingConfig = await readJSONFile(configPath);
1763
1857
  if (existingConfig instanceof CantParseJSONFile) {
1764
1858
  throw existingConfig;
@@ -1863,9 +1957,13 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1863
1957
  routesResult.routes,
1864
1958
  detectedExperimentalServicesV2RootRoutes ?? existingConfig?.routes
1865
1959
  );
1960
+ const mergedRoutesWithGeneratedServicesV2Routes = nestExperimentalServicesV2Output ? appendBuildOutputRouteTables(
1961
+ mergedRoutes,
1962
+ detectedExperimentalServicesV2RootRoutes ?? existingConfig?.routes
1963
+ ) : mergedRoutes;
1866
1964
  const config = {
1867
1965
  version: 3,
1868
- routes: nestExperimentalServicesV2Output ? explicitRootRoutes : mergedRoutes,
1966
+ routes: mergedRoutesWithGeneratedServicesV2Routes ?? explicitRootRoutes,
1869
1967
  images: mergedImages,
1870
1968
  wildcard: mergedWildcard,
1871
1969
  overrides: mergedOverrides,
@@ -1882,7 +1980,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1882
1980
  },
1883
1981
  ...mergedDeploymentId && { deploymentId: mergedDeploymentId }
1884
1982
  };
1885
- await import_fs_extra2.default.writeJSON(join3(outputDir, "config.json"), config, { spaces: 2 });
1983
+ await import_fs_extra2.default.writeJSON(join4(outputDir, "config.json"), config, { spaces: 2 });
1886
1984
  if (nestExperimentalServicesV2Output) {
1887
1985
  await writeServiceConfigs(
1888
1986
  outputDir,
@@ -1894,7 +1992,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1894
1992
  }
1895
1993
  await writeFlagsJSON(buildResults.values(), outputDir);
1896
1994
  collectSpan.stop();
1897
- const relOutputDir = relative2(cwd, outputDir);
1995
+ const relOutputDir = relative3(cwd, outputDir);
1898
1996
  if (!client.nonInteractive) {
1899
1997
  output_manager_default.print(
1900
1998
  `${prependEmoji(
@@ -1911,7 +2009,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1911
2009
  }
1912
2010
  }
1913
2011
  function getFunctionUrlPath(vcConfigPath, outputDir) {
1914
- const funcPath = normalizePath(relative2(outputDir, vcConfigPath)).replace(/^functions\//, "").replace(/\/\.vc-config\.json$/, "").replace(/\.func$/, "");
2012
+ const funcPath = normalizePath(relative3(outputDir, vcConfigPath)).replace(/^functions\//, "").replace(/\/\.vc-config\.json$/, "").replace(/\.func$/, "");
1915
2013
  return "/" + funcPath.split("/").filter((part) => part && part !== "index").join("/");
1916
2014
  }
1917
2015
  var LAMBDA_SIZE_LIMIT_MB = 250;
@@ -1940,7 +2038,7 @@ async function analyzeVcConfigFiles(cwd, outputDir) {
1940
2038
  const filesObject = await glob("**/.vc-config.json", {
1941
2039
  cwd: outputDir
1942
2040
  });
1943
- const vcConfigFiles = Object.keys(filesObject).filter((relativePath) => !relativePath.includes(".rsc.func")).map((relativePath) => join3(outputDir, relativePath));
2041
+ const vcConfigFiles = Object.keys(filesObject).filter((relativePath) => !relativePath.includes(".rsc.func")).map((relativePath) => join4(outputDir, relativePath));
1944
2042
  if (vcConfigFiles.length === 0) {
1945
2043
  output_manager_default.print("No functions to analyze.\n");
1946
2044
  return;
@@ -2002,13 +2100,13 @@ async function analyzeSingleFunction(file, cwd, outputDir) {
2002
2100
  try {
2003
2101
  const content = await import_fs_extra2.default.readFile(file, "utf8");
2004
2102
  const parsed = JSON.parse(content);
2005
- const funcDir = dirname(file);
2103
+ const funcDir = dirname2(file);
2006
2104
  const funcDirStats = getDirectorySizeInMB(funcDir);
2007
2105
  const filePathMap = parsed.filePathMap && typeof parsed.filePathMap === "object" ? Object.entries(parsed.filePathMap).filter(
2008
2106
  (entry) => typeof entry[1] === "string"
2009
2107
  ).map(([bundlePath, sourcePath]) => ({
2010
2108
  bundlePath,
2011
- sourcePath: join3(cwd, sourcePath)
2109
+ sourcePath: join4(cwd, sourcePath)
2012
2110
  })) : [];
2013
2111
  const fsRefStats = getTotalFileSizeInMB(filePathMap);
2014
2112
  const totalSize = funcDirStats.size + fsRefStats.size;
@@ -2047,7 +2145,7 @@ function getDirectorySizeInMB(dir) {
2047
2145
  const entries = readdirSync(dir, { recursive: true });
2048
2146
  for (const entry of entries) {
2049
2147
  const entryPath = typeof entry === "string" ? entry : entry.toString();
2050
- const fullPath = join3(dir, entryPath);
2148
+ const fullPath = join4(dir, entryPath);
2051
2149
  try {
2052
2150
  const stats = statSync(fullPath);
2053
2151
  if (stats.isFile()) {
@@ -2202,7 +2300,7 @@ async function writeServiceConfigs(outputDir, buildResults, serviceByBuilder, se
2202
2300
  }
2203
2301
  await Promise.all(
2204
2302
  Array.from(serviceResults.entries()).map(async ([serviceName, results]) => {
2205
- const configPath = join3(
2303
+ const configPath = join4(
2206
2304
  outputDir,
2207
2305
  "services",
2208
2306
  serviceName,
@@ -2293,7 +2391,7 @@ async function mergeDeploymentId(existingDeploymentId, buildResults, workPath) {
2293
2391
  }
2294
2392
  }
2295
2393
  try {
2296
- const routesManifestPath = join3(workPath, ".next", "routes-manifest.json");
2394
+ const routesManifestPath = join4(workPath, ".next", "routes-manifest.json");
2297
2395
  if (await import_fs_extra2.default.pathExists(routesManifestPath)) {
2298
2396
  const routesManifest = await readJSONFile(
2299
2397
  routesManifestPath
@@ -2309,7 +2407,7 @@ async function mergeDeploymentId(existingDeploymentId, buildResults, workPath) {
2309
2407
  return void 0;
2310
2408
  }
2311
2409
  async function writeFlagsJSON(buildResults, outputDir) {
2312
- const flagsFilePath = join3(outputDir, "flags.json");
2410
+ const flagsFilePath = join4(outputDir, "flags.json");
2313
2411
  let hasFlags = true;
2314
2412
  const flags = await import_fs_extra2.default.readJSON(flagsFilePath).catch((error) => {
2315
2413
  if (error.code === "ENOENT") {
@@ -2337,7 +2435,7 @@ async function writeFlagsJSON(buildResults, outputDir) {
2337
2435
  }
2338
2436
  }
2339
2437
  async function writeBuildJson(buildsJson, outputDir) {
2340
- await import_fs_extra2.default.writeJSON(join3(outputDir, "builds.json"), buildsJson, { spaces: 2 });
2438
+ await import_fs_extra2.default.writeJSON(join4(outputDir, "builds.json"), buildsJson, { spaces: 2 });
2341
2439
  }
2342
2440
  async function getFrameworkRoutes(framework, dirPrefix) {
2343
2441
  let routes = [];
@@ -13,10 +13,10 @@ import {
13
13
  purchaseDomainIfAvailable,
14
14
  require_cjs,
15
15
  setupDomain
16
- } from "../../chunks/chunk-3WENOEKR.js";
16
+ } from "../../chunks/chunk-FM24W7ET.js";
17
17
  import {
18
18
  readLocalConfig
19
- } from "../../chunks/chunk-DHLDURNP.js";
19
+ } from "../../chunks/chunk-FZZWTDNQ.js";
20
20
  import {
21
21
  highlight
22
22
  } from "../../chunks/chunk-V5P25P7F.js";
@@ -40,7 +40,10 @@ import {
40
40
  deprecatedArchiveSplitTgz,
41
41
  getCommandAliases,
42
42
  initSubcommand
43
- } from "../../chunks/chunk-BSSEGYXP.js";
43
+ } from "../../chunks/chunk-WFXGLPSI.js";
44
+ import "../../chunks/chunk-KXGWAWRV.js";
45
+ import "../../chunks/chunk-RY3AVR6E.js";
46
+ import "../../chunks/chunk-AUECDTMX.js";
44
47
  import "../../chunks/chunk-MAJWH2PD.js";
45
48
  import "../../chunks/chunk-EFUR47FZ.js";
46
49
  import "../../chunks/chunk-UJ5UEAMC.js";
@@ -50,7 +53,7 @@ import "../../chunks/chunk-DFEUWDGM.js";
50
53
  import "../../chunks/chunk-FNRZFHFO.js";
51
54
  import {
52
55
  pickOverrides
53
- } from "../../chunks/chunk-22CQWS5E.js";
56
+ } from "../../chunks/chunk-5MVXR7B7.js";
54
57
  import "../../chunks/chunk-NJUPUGOE.js";
55
58
  import {
56
59
  stamp_default
@@ -58,17 +61,17 @@ import {
58
61
  import "../../chunks/chunk-VXYGCOKL.js";
59
62
  import {
60
63
  ensureLink
61
- } from "../../chunks/chunk-ODVBO56J.js";
64
+ } from "../../chunks/chunk-Q7GZMMHB.js";
62
65
  import {
63
66
  validatePaths,
64
67
  validateRootDirectory
65
- } from "../../chunks/chunk-VKGCONIM.js";
68
+ } from "../../chunks/chunk-6ISLGUMI.js";
66
69
  import {
67
70
  AGENT_STATUS
68
71
  } from "../../chunks/chunk-QH7WYDEP.js";
69
- import "../../chunks/chunk-V7IBBQ2D.js";
70
- import "../../chunks/chunk-I43WUYKE.js";
71
- import "../../chunks/chunk-BI2IN6RX.js";
72
+ import "../../chunks/chunk-YWLVPKNT.js";
73
+ import "../../chunks/chunk-O2QNLUYX.js";
74
+ import "../../chunks/chunk-P726GMBL.js";
72
75
  import {
73
76
  help
74
77
  } from "../../chunks/chunk-YSIZGIDP.js";
@@ -85,7 +88,7 @@ import {
85
88
  require_dist as require_dist2,
86
89
  require_frameworks,
87
90
  require_lib
88
- } from "../../chunks/chunk-F6YGVA2L.js";
91
+ } from "../../chunks/chunk-RB7WQKNC.js";
89
92
  import {
90
93
  outputAgentError
91
94
  } from "../../chunks/chunk-IZOHLD5D.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "../../chunks/chunk-2HSQ7YUK.js";
10
10
  import {
11
11
  getUpdateCommand
12
- } from "../../chunks/chunk-GXAVQSHO.js";
12
+ } from "../../chunks/chunk-FVI6UYNL.js";
13
13
  import {
14
14
  highlight
15
15
  } from "../../chunks/chunk-V5P25P7F.js";
@@ -26,23 +26,23 @@ import {
26
26
  require_mime_types,
27
27
  require_npa,
28
28
  staticFiles
29
- } from "../../chunks/chunk-CXGDCPH4.js";
29
+ } from "../../chunks/chunk-ITU4COOO.js";
30
30
  import "../../chunks/chunk-IB5L4LKZ.js";
31
31
  import {
32
32
  pickOverrides
33
- } from "../../chunks/chunk-22CQWS5E.js";
33
+ } from "../../chunks/chunk-5MVXR7B7.js";
34
34
  import "../../chunks/chunk-24FCBXI4.js";
35
35
  import {
36
36
  displayDetectedServices,
37
37
  printProjectNotFoundError,
38
38
  readConfig,
39
39
  setupAndLink
40
- } from "../../chunks/chunk-VKGCONIM.js";
40
+ } from "../../chunks/chunk-6ISLGUMI.js";
41
41
  import "../../chunks/chunk-QH7WYDEP.js";
42
42
  import {
43
43
  getLocalPathConfig
44
- } from "../../chunks/chunk-V7IBBQ2D.js";
45
- import "../../chunks/chunk-BI2IN6RX.js";
44
+ } from "../../chunks/chunk-YWLVPKNT.js";
45
+ import "../../chunks/chunk-P726GMBL.js";
46
46
  import {
47
47
  help
48
48
  } from "../../chunks/chunk-YSIZGIDP.js";
@@ -71,7 +71,7 @@ import {
71
71
  resolveProjectCwd,
72
72
  tryDetectServices,
73
73
  validateConfig
74
- } from "../../chunks/chunk-F6YGVA2L.js";
74
+ } from "../../chunks/chunk-RB7WQKNC.js";
75
75
  import {
76
76
  buildCommandWithYes,
77
77
  outputActionRequired
@@ -20758,7 +20758,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
20758
20758
  return void 0;
20759
20759
  }
20760
20760
  async _getVercelConfig() {
20761
- const { compileVercelConfig } = await import("../../chunks/compile-vercel-config-WRCB2TG2.js");
20761
+ const { compileVercelConfig } = await import("../../chunks/compile-vercel-config-XEZ2TPQ4.js");
20762
20762
  await compileVercelConfig(this.cwd);
20763
20763
  const configPath = getLocalPathConfig(this.cwd);
20764
20764
  const [
@@ -110,6 +110,7 @@ function emitWebSocketRequest({
110
110
  }
111
111
  consumed = true;
112
112
 
113
+ const closeResponse = createResponseCloseEmitter(response);
113
114
  if (typeof response.detachSocket === 'function') {
114
115
  response.detachSocket(socket);
115
116
  }
@@ -120,6 +121,7 @@ function emitWebSocketRequest({
120
121
  requestContext.run(context, () => {
121
122
  req.emit('aborted');
122
123
  abortController.abort();
124
+ closeResponse();
123
125
  });
124
126
  });
125
127
  socket.once('error', noop);
@@ -169,6 +171,24 @@ function suppressFrameworkResponse(response) {
169
171
  };
170
172
  }
171
173
 
174
+ function createResponseCloseEmitter(response) {
175
+ let closed = false;
176
+ response.once('close', () => {
177
+ closed = true;
178
+ });
179
+
180
+ return () => {
181
+ if (closed) {
182
+ return;
183
+ }
184
+ closed = true;
185
+ // Frameworks like Next.js use ServerResponse "close" as their request
186
+ // lifecycle hook. Upgraded requests detach the socket, so bridge that
187
+ // hook to the WebSocket close.
188
+ response.emit('close');
189
+ };
190
+ }
191
+
172
192
  function preserveAsyncContextOnSocket(socket, requestContext) {
173
193
  const store = requestContext.getStore();
174
194
  const runInSnapshot =