@vercel/next 4.5.1 → 4.6.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 (2) hide show
  1. package/dist/index.js +280 -104
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -790,17 +790,43 @@ var require_dist2 = __commonJS({
790
790
  }
791
791
  });
792
792
 
793
- // ../../internals/path-to-regexp/dist/index.js
794
- var require_dist3 = __commonJS({
795
- "../../internals/path-to-regexp/dist/index.js"(exports) {
793
+ // ../routing-utils/dist/superstatic.js
794
+ var require_superstatic = __commonJS({
795
+ "../routing-utils/dist/superstatic.js"(exports, module2) {
796
796
  "use strict";
797
- Object.defineProperty(exports, "__esModule", { value: true });
798
- exports.compile = exports.pathToRegexp = void 0;
799
- var path_to_regexp_1 = require_dist();
800
- Object.defineProperty(exports, "compile", { enumerable: true, get: function() {
801
- return path_to_regexp_1.compile;
802
- } });
803
- var path_to_regexp_updated_1 = require_dist2();
797
+ var __defProp2 = Object.defineProperty;
798
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
799
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
800
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
801
+ var __export2 = (target, all) => {
802
+ for (var name in all)
803
+ __defProp2(target, name, { get: all[name], enumerable: true });
804
+ };
805
+ var __copyProps2 = (to, from, except, desc) => {
806
+ if (from && typeof from === "object" || typeof from === "function") {
807
+ for (let key of __getOwnPropNames2(from))
808
+ if (!__hasOwnProp2.call(to, key) && key !== except)
809
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
810
+ }
811
+ return to;
812
+ };
813
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
814
+ var superstatic_exports = {};
815
+ __export2(superstatic_exports, {
816
+ collectHasSegments: () => collectHasSegments,
817
+ convertCleanUrls: () => convertCleanUrls,
818
+ convertHeaders: () => convertHeaders2,
819
+ convertRedirects: () => convertRedirects2,
820
+ convertRewrites: () => convertRewrites2,
821
+ convertTrailingSlash: () => convertTrailingSlash,
822
+ getCleanUrls: () => getCleanUrls,
823
+ pathToRegexp: () => pathToRegexp,
824
+ sourceToRegex: () => sourceToRegex
825
+ });
826
+ module2.exports = __toCommonJS2(superstatic_exports);
827
+ var import_url4 = require("url");
828
+ var import_path_to_regexp = require_dist();
829
+ var import_path_to_regexp_updated = require_dist2();
804
830
  function cloneKeys(keys) {
805
831
  if (typeof keys === "undefined") {
806
832
  return void 0;
@@ -814,10 +840,10 @@ var require_dist3 = __commonJS({
814
840
  }
815
841
  function pathToRegexp(callerId, path5, keys, options) {
816
842
  const newKeys = cloneKeys(keys);
817
- const currentRegExp = (0, path_to_regexp_1.pathToRegexp)(path5, keys, options);
843
+ const currentRegExp = (0, import_path_to_regexp.pathToRegexp)(path5, keys, options);
818
844
  try {
819
845
  const currentKeys = keys;
820
- const newRegExp = (0, path_to_regexp_updated_1.pathToRegexp)(path5, newKeys, options);
846
+ const newRegExp = (0, import_path_to_regexp_updated.pathToRegexp)(path5, newKeys, options);
821
847
  const isDiffRegExp = currentRegExp.toString() !== newRegExp.toString();
822
848
  if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffRegExp) {
823
849
  const message = JSON.stringify({
@@ -846,45 +872,6 @@ var require_dist3 = __commonJS({
846
872
  }
847
873
  return currentRegExp;
848
874
  }
849
- exports.pathToRegexp = pathToRegexp;
850
- }
851
- });
852
-
853
- // ../routing-utils/dist/superstatic.js
854
- var require_superstatic = __commonJS({
855
- "../routing-utils/dist/superstatic.js"(exports, module2) {
856
- "use strict";
857
- var __defProp2 = Object.defineProperty;
858
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
859
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
860
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
861
- var __export2 = (target, all) => {
862
- for (var name in all)
863
- __defProp2(target, name, { get: all[name], enumerable: true });
864
- };
865
- var __copyProps2 = (to, from, except, desc) => {
866
- if (from && typeof from === "object" || typeof from === "function") {
867
- for (let key of __getOwnPropNames2(from))
868
- if (!__hasOwnProp2.call(to, key) && key !== except)
869
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
870
- }
871
- return to;
872
- };
873
- var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
874
- var superstatic_exports = {};
875
- __export2(superstatic_exports, {
876
- collectHasSegments: () => collectHasSegments,
877
- convertCleanUrls: () => convertCleanUrls,
878
- convertHeaders: () => convertHeaders2,
879
- convertRedirects: () => convertRedirects2,
880
- convertRewrites: () => convertRewrites2,
881
- convertTrailingSlash: () => convertTrailingSlash,
882
- getCleanUrls: () => getCleanUrls,
883
- sourceToRegex: () => sourceToRegex
884
- });
885
- module2.exports = __toCommonJS2(superstatic_exports);
886
- var import_url4 = require("url");
887
- var import_path_to_regexp = require_dist3();
888
875
  var UN_NAMED_SEGMENT = "__UN_NAMED_SEGMENT__";
889
876
  function getCleanUrls(filePaths) {
890
877
  const htmlFiles = filePaths.map(toRoute).filter((f) => f.endsWith(".html")).map((f) => ({
@@ -1040,7 +1027,7 @@ var require_superstatic = __commonJS({
1040
1027
  }
1041
1028
  function sourceToRegex(source) {
1042
1029
  const keys = [];
1043
- const r = (0, import_path_to_regexp.pathToRegexp)("632", source, keys, {
1030
+ const r = pathToRegexp("632", source, keys, {
1044
1031
  strict: true,
1045
1032
  sensitive: true,
1046
1033
  delimiter: "/"
@@ -1113,9 +1100,9 @@ var require_superstatic = __commonJS({
1113
1100
  const hashKeys = [];
1114
1101
  const hostnameKeys = [];
1115
1102
  try {
1116
- (0, import_path_to_regexp.pathToRegexp)("528", pathname, pathnameKeys);
1117
- (0, import_path_to_regexp.pathToRegexp)("834", hash || "", hashKeys);
1118
- (0, import_path_to_regexp.pathToRegexp)("712", hostname || "", hostnameKeys);
1103
+ pathToRegexp("528", pathname, pathnameKeys);
1104
+ pathToRegexp("834", hash || "", hashKeys);
1105
+ pathToRegexp("712", hostname || "", hostnameKeys);
1119
1106
  } catch (_) {
1120
1107
  }
1121
1108
  destParams = new Set(
@@ -11136,7 +11123,8 @@ async function getDynamicRoutes({
11136
11123
  bypassToken,
11137
11124
  isServerMode,
11138
11125
  dynamicMiddlewareRouteMap,
11139
- isAppPPREnabled
11126
+ isAppPPREnabled,
11127
+ isAppClientSegmentCacheEnabled
11140
11128
  }) {
11141
11129
  if (routesManifest) {
11142
11130
  switch (routesManifest.version) {
@@ -11169,7 +11157,13 @@ async function getDynamicRoutes({
11169
11157
  routes2.push(route2);
11170
11158
  continue;
11171
11159
  }
11172
- const { page, namedRegex, regex, routeKeys } = params;
11160
+ const {
11161
+ page,
11162
+ namedRegex,
11163
+ regex,
11164
+ routeKeys,
11165
+ prefetchSegmentDataRoutes
11166
+ } = params;
11173
11167
  const route = {
11174
11168
  src: namedRegex || regex,
11175
11169
  dest: `${!isDev ? import_path2.default.posix.join("/", entryDirectory, page) : page}${routeKeys ? `?${Object.keys(routeKeys).map((key) => `${routeKeys[key]}=$${key}`).join("&")}` : ""}`
@@ -11190,6 +11184,20 @@ async function getDynamicRoutes({
11190
11184
  }
11191
11185
  ];
11192
11186
  }
11187
+ if (isAppClientSegmentCacheEnabled && prefetchSegmentDataRoutes && prefetchSegmentDataRoutes.length > 0) {
11188
+ for (const prefetchSegmentDataRoute of prefetchSegmentDataRoutes) {
11189
+ routes2.push({
11190
+ ...route,
11191
+ src: prefetchSegmentDataRoute.source,
11192
+ dest: `${!isDev ? import_path2.default.posix.join(
11193
+ "/",
11194
+ entryDirectory,
11195
+ prefetchSegmentDataRoute.destination
11196
+ ) : prefetchSegmentDataRoute.destination}${routeKeys ? `?${Object.entries(routeKeys).map(([key, value]) => `${value}=$${key}`).join("&")}` : ""}`,
11197
+ check: true
11198
+ });
11199
+ }
11200
+ }
11193
11201
  if (isAppPPREnabled) {
11194
11202
  let dest = route.dest?.replace(/($|\?)/, ".prefetch.rsc$1");
11195
11203
  if (page === "/" || page === "/index") {
@@ -12129,7 +12137,8 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12129
12137
  routesManifest,
12130
12138
  isCorrectNotFoundRoutes,
12131
12139
  isEmptyAllowQueryForPrendered,
12132
- isAppPPREnabled
12140
+ isAppPPREnabled,
12141
+ isAppClientSegmentCacheEnabled
12133
12142
  } = prerenderRouteArgs;
12134
12143
  if (isBlocking && isFallback) {
12135
12144
  throw new import_build_utils.NowBuildError({
@@ -12246,7 +12255,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12246
12255
  const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
12247
12256
  if (import_fs_extra3.default.existsSync(htmlPath) && import_fs_extra3.default.existsSync(metaPath)) {
12248
12257
  const meta = JSON.parse(await import_fs_extra3.default.readFile(metaPath, "utf8"));
12249
- if ("postponed" in meta && typeof meta.postponed === "string") {
12258
+ if (typeof meta === "object" && meta !== null && "postponed" in meta && typeof meta.postponed === "string") {
12250
12259
  didPostpone = true;
12251
12260
  postponedPrerender = meta.postponed;
12252
12261
  initialHeaders ??= {};
@@ -12547,6 +12556,53 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12547
12556
  prerenders[normalizePathData(outputPathData)] = prerender;
12548
12557
  }
12549
12558
  }
12559
+ const prefetchSegmentSuffix = routesManifest?.rsc?.prefetchSegmentSuffix;
12560
+ const prefetchSegmentDirSuffix = routesManifest?.rsc?.prefetchSegmentDirSuffix;
12561
+ if (isAppClientSegmentCacheEnabled && prefetchSegmentSuffix && prefetchSegmentDirSuffix && rscDidPostponeHeader && appDir) {
12562
+ const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
12563
+ if (import_fs_extra3.default.existsSync(metaPath)) {
12564
+ const meta = JSON.parse(await import_fs_extra3.default.readFile(metaPath, "utf8"));
12565
+ if (typeof meta === "object" && meta !== null && "segmentPaths" in meta && typeof meta.segmentPaths === "object" && meta.segmentPaths !== null && Array.isArray(meta.segmentPaths)) {
12566
+ const segmentsDir = import_path2.default.join(
12567
+ appDir,
12568
+ routeFileNoExt + prefetchSegmentDirSuffix
12569
+ );
12570
+ for (const segmentPath of meta.segmentPaths) {
12571
+ const outputSegmentPath = import_path2.default.join(
12572
+ outputPathPage + prefetchSegmentDirSuffix,
12573
+ segmentPath
12574
+ ) + prefetchSegmentSuffix;
12575
+ let fallback = null;
12576
+ if (!isFallback) {
12577
+ const fsPath = import_path2.default.join(
12578
+ segmentsDir,
12579
+ segmentPath + prefetchSegmentSuffix
12580
+ );
12581
+ fallback = new import_build_utils.FileFsRef({ fsPath });
12582
+ }
12583
+ prerenders[outputSegmentPath] = new import_build_utils.Prerender({
12584
+ expiration: initialRevalidate,
12585
+ lambda,
12586
+ allowQuery,
12587
+ fallback,
12588
+ // Use the same prerender group as the JSON/data prerender.
12589
+ group: prerenderGroup,
12590
+ allowHeader,
12591
+ // These routes are always only static, so they should not
12592
+ // permit any bypass unless it's for preview
12593
+ bypassToken: prerenderManifest.bypassToken,
12594
+ experimentalBypassFor: void 0,
12595
+ initialHeaders: {
12596
+ ...initialHeaders,
12597
+ vary: rscVaryHeader,
12598
+ "content-type": rscContentTypeHeader,
12599
+ [rscDidPostponeHeader]: "2"
12600
+ }
12601
+ });
12602
+ }
12603
+ }
12604
+ }
12605
+ }
12550
12606
  if (outputPathData?.endsWith(".json") && appDir) {
12551
12607
  const dummyOutput = new import_build_utils.FileBlob({
12552
12608
  data: "{}",
@@ -13646,7 +13702,8 @@ async function serverBuild({
13646
13702
  requiredServerFilesManifest,
13647
13703
  variantsManifest,
13648
13704
  experimentalPPRRoutes,
13649
- isAppPPREnabled
13705
+ isAppPPREnabled,
13706
+ isAppClientSegmentCacheEnabled
13650
13707
  }) {
13651
13708
  if (isAppPPREnabled) {
13652
13709
  (0, import_build_utils2.debug)(
@@ -13699,10 +13756,17 @@ async function serverBuild({
13699
13756
  continue;
13700
13757
  const { protocol, pathname, query } = import_url2.default.parse(rewrite.dest);
13701
13758
  if (isAfterFilesRewrite) {
13702
- const rscSuffix = isAppPPREnabled ? `(\\.prefetch)?\\.rsc` : "\\.rsc";
13759
+ const parts = ["\\.rsc"];
13760
+ if (isAppPPREnabled) {
13761
+ parts.push("\\.prefetch\\.rsc");
13762
+ }
13763
+ if (isAppClientSegmentCacheEnabled) {
13764
+ parts.push("\\.segments/.+\\.segment\\.rsc");
13765
+ }
13766
+ const rscSuffix = parts.join("|");
13703
13767
  rewrite.src = rewrite.src.replace(
13704
13768
  /\/?\(\?:\/\)\?/,
13705
- `(?<rscsuff>${rscSuffix})?(?:/)?`
13769
+ `(?:/)?(?<rscsuff>${rscSuffix})?`
13706
13770
  );
13707
13771
  let destQueryIndex = rewrite.dest.indexOf("?");
13708
13772
  if (destQueryIndex === -1) {
@@ -13756,6 +13820,9 @@ async function serverBuild({
13756
13820
  ) : {};
13757
13821
  const updated = {
13758
13822
  ...rewrite,
13823
+ // We don't want to perform the actual rewrite here, instead we want
13824
+ // to just add the headers associated with the rewrite.
13825
+ dest: void 0,
13759
13826
  has,
13760
13827
  headers: headers2
13761
13828
  };
@@ -14597,7 +14664,8 @@ ${JSON.stringify(
14597
14664
  hasPages404: routesManifest.pages404,
14598
14665
  isCorrectNotFoundRoutes,
14599
14666
  isEmptyAllowQueryForPrendered,
14600
- isAppPPREnabled
14667
+ isAppPPREnabled,
14668
+ isAppClientSegmentCacheEnabled
14601
14669
  });
14602
14670
  await Promise.all(
14603
14671
  Object.keys(prerenderManifest.staticRoutes).map(
@@ -14662,7 +14730,8 @@ ${JSON.stringify(
14662
14730
  bypassToken: prerenderManifest.bypassToken || "",
14663
14731
  isServerMode: true,
14664
14732
  dynamicMiddlewareRouteMap: middleware.dynamicRouteMap,
14665
- isAppPPREnabled
14733
+ isAppPPREnabled,
14734
+ isAppClientSegmentCacheEnabled
14666
14735
  }).then(
14667
14736
  (arr) => localizeDynamicRoutes(
14668
14737
  arr,
@@ -14822,6 +14891,9 @@ ${JSON.stringify(
14822
14891
  }
14823
14892
  }
14824
14893
  }
14894
+ const prefetchSegmentHeader = routesManifest?.rsc?.prefetchSegmentHeader;
14895
+ const prefetchSegmentDirSuffix = routesManifest?.rsc?.prefetchSegmentDirSuffix;
14896
+ const prefetchSegmentSuffix = routesManifest?.rsc?.prefetchSegmentSuffix;
14825
14897
  const rscPrefetchHeader = routesManifest.rsc?.prefetchHeader?.toLowerCase();
14826
14898
  const rscVaryHeader = routesManifest?.rsc?.varyHeader || "RSC, Next-Router-State-Tree, Next-Router-Prefetch";
14827
14899
  const appNotFoundPath = import_path4.default.posix.join(".", entryDirectory, "_not-found");
@@ -15055,9 +15127,65 @@ ${JSON.stringify(
15055
15127
  // to prevent a local/deploy mismatch
15056
15128
  ...!isCorrectMiddlewareOrder ? middleware.staticRoutes : [],
15057
15129
  ...appDir ? [
15130
+ ...isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix ? [
15131
+ {
15132
+ src: import_path4.default.posix.join("/", entryDirectory, "/(?<path>.+)$"),
15133
+ dest: import_path4.default.posix.join(
15134
+ "/",
15135
+ entryDirectory,
15136
+ `/$path${prefetchSegmentDirSuffix}/$segmentPath${prefetchSegmentSuffix}`
15137
+ ),
15138
+ has: [
15139
+ {
15140
+ type: "header",
15141
+ key: rscHeader,
15142
+ value: "1"
15143
+ },
15144
+ {
15145
+ type: "header",
15146
+ key: rscPrefetchHeader,
15147
+ value: "1"
15148
+ },
15149
+ {
15150
+ type: "header",
15151
+ key: prefetchSegmentHeader,
15152
+ value: "/(?<segmentPath>.+)"
15153
+ }
15154
+ ],
15155
+ continue: true,
15156
+ override: true
15157
+ },
15158
+ {
15159
+ src: import_path4.default.posix.join("^/", entryDirectory, "$"),
15160
+ dest: import_path4.default.posix.join(
15161
+ "/",
15162
+ entryDirectory,
15163
+ `/index${prefetchSegmentDirSuffix}/$segmentPath${prefetchSegmentSuffix}`
15164
+ ),
15165
+ has: [
15166
+ {
15167
+ type: "header",
15168
+ key: rscHeader,
15169
+ value: "1"
15170
+ },
15171
+ {
15172
+ type: "header",
15173
+ key: rscPrefetchHeader,
15174
+ value: "1"
15175
+ },
15176
+ {
15177
+ type: "header",
15178
+ key: prefetchSegmentHeader,
15179
+ value: "/(?<segmentPath>.+)"
15180
+ }
15181
+ ],
15182
+ continue: true,
15183
+ override: true
15184
+ }
15185
+ ] : [],
15058
15186
  ...rscPrefetchHeader && isAppPPREnabled ? [
15059
15187
  {
15060
- src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
15188
+ src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}$`,
15061
15189
  has: [
15062
15190
  {
15063
15191
  type: "header",
@@ -15369,6 +15497,23 @@ ${JSON.stringify(
15369
15497
  dest: "__next_data_catchall"
15370
15498
  }
15371
15499
  ] : [],
15500
+ // If it didn't match any of the static routes or dynamic ones, then we
15501
+ // should fallback to the regular RSC request.
15502
+ ...isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix ? [
15503
+ {
15504
+ src: import_path4.default.posix.join(
15505
+ "/",
15506
+ entryDirectory,
15507
+ `/(?<path>.+)${(0, import_escape_string_regexp2.default)(prefetchSegmentDirSuffix)}/.+${(0, import_escape_string_regexp2.default)(prefetchSegmentSuffix)}$`
15508
+ ),
15509
+ dest: import_path4.default.posix.join(
15510
+ "/",
15511
+ entryDirectory,
15512
+ isAppPPREnabled ? "/$path.prefetch.rsc" : "/$path.rsc"
15513
+ ),
15514
+ check: true
15515
+ }
15516
+ ] : [],
15372
15517
  // routes to call after a file has been matched
15373
15518
  { handle: "hit" },
15374
15519
  // Before we handle static files we need to set proper caching headers
@@ -15558,6 +15703,7 @@ function isLegacyNext(nextVersion) {
15558
15703
  }
15559
15704
  var build = async (buildOptions) => {
15560
15705
  let { workPath, repoRootPath } = buildOptions;
15706
+ const buildSpan = buildOptions.span ?? new import_build_utils3.Span({ name: import_build_utils3.BUILDER_COMPILE_STEP });
15561
15707
  const {
15562
15708
  files,
15563
15709
  entrypoint,
@@ -15664,18 +15810,38 @@ var build = async (buildOptions) => {
15664
15810
  (0, import_build_utils3.debug)("Found NPM_AUTH_TOKEN in environment, creating .npmrc");
15665
15811
  await writeNpmRc(entryPath, process.env.NPM_AUTH_TOKEN);
15666
15812
  }
15667
- if (typeof installCommand === "string") {
15668
- if (installCommand.trim()) {
15669
- console.log(`Running "install" command: \`${installCommand}\`...`);
15670
- await (0, import_build_utils3.execCommand)(installCommand, {
15671
- ...spawnOpts,
15672
- cwd: entryPath
15673
- });
15674
- } else {
15675
- console.log(`Skipping "install" command...`);
15676
- }
15813
+ const { detectedPackageManager } = (0, import_build_utils3.detectPackageManager)(cliType, lockfileVersion) ?? {};
15814
+ const trimmedInstallCommand = installCommand?.trim();
15815
+ const shouldRunInstallCommand = (
15816
+ // Case 1: We have a zero config install
15817
+ typeof trimmedInstallCommand === "undefined" || // Case 1: We have a install command which is non zero length
15818
+ Boolean(trimmedInstallCommand)
15819
+ );
15820
+ buildSpan.setAttributes({
15821
+ install: JSON.stringify(shouldRunInstallCommand)
15822
+ });
15823
+ if (shouldRunInstallCommand) {
15824
+ await buildSpan.child(import_build_utils3.BUILDER_INSTALLER_STEP, {
15825
+ cliType,
15826
+ lockfileVersion: lockfileVersion?.toString(),
15827
+ packageJsonPackageManager,
15828
+ detectedPackageManager,
15829
+ installCommand: trimmedInstallCommand
15830
+ }).trace(async () => {
15831
+ if (typeof trimmedInstallCommand === "string") {
15832
+ console.log(
15833
+ `Running "install" command: \`${trimmedInstallCommand}\`...`
15834
+ );
15835
+ await (0, import_build_utils3.execCommand)(trimmedInstallCommand, {
15836
+ ...spawnOpts,
15837
+ cwd: entryPath
15838
+ });
15839
+ } else {
15840
+ await (0, import_build_utils3.runNpmInstall)(entryPath, [], spawnOpts, meta, nodeVersion);
15841
+ }
15842
+ });
15677
15843
  } else {
15678
- await (0, import_build_utils3.runNpmInstall)(entryPath, [], spawnOpts, meta, nodeVersion);
15844
+ console.log(`Skipping "install" command...`);
15679
15845
  }
15680
15846
  if (spawnOpts.env.VERCEL_ANALYTICS_ID) {
15681
15847
  (0, import_build_utils3.debug)("Found VERCEL_ANALYTICS_ID in environment");
@@ -15743,31 +15909,36 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15743
15909
  if (isServerMode) {
15744
15910
  env.NODE_ENV = "production";
15745
15911
  }
15746
- if (buildCommand) {
15747
- const nodeBinPaths = (0, import_build_utils3.getNodeBinPaths)({
15748
- start: entryPath,
15749
- base: repoRootPath
15750
- });
15751
- const nodeBinPath = nodeBinPaths.join(import_path5.default.delimiter);
15752
- env.PATH = `${nodeBinPath}${import_path5.default.delimiter}${env.PATH}`;
15753
- if (!env.YARN_NODE_LINKER) {
15754
- env.YARN_NODE_LINKER = "node-modules";
15912
+ await buildSpan.child(import_build_utils3.BUILDER_COMPILE_STEP, {
15913
+ buildCommand,
15914
+ buildScriptName
15915
+ }).trace(async () => {
15916
+ if (buildCommand) {
15917
+ const nodeBinPaths = (0, import_build_utils3.getNodeBinPaths)({
15918
+ start: entryPath,
15919
+ base: repoRootPath
15920
+ });
15921
+ const nodeBinPath = nodeBinPaths.join(import_path5.default.delimiter);
15922
+ env.PATH = `${nodeBinPath}${import_path5.default.delimiter}${env.PATH}`;
15923
+ if (!env.YARN_NODE_LINKER) {
15924
+ env.YARN_NODE_LINKER = "node-modules";
15925
+ }
15926
+ (0, import_build_utils3.debug)(
15927
+ `Added "${nodeBinPath}" to PATH env because a build command was used.`
15928
+ );
15929
+ console.log(`Running "${buildCommand}"`);
15930
+ await (0, import_build_utils3.execCommand)(buildCommand, {
15931
+ ...spawnOpts,
15932
+ cwd: entryPath,
15933
+ env
15934
+ });
15935
+ } else if (buildScriptName) {
15936
+ await (0, import_build_utils3.runPackageJsonScript)(entryPath, buildScriptName, {
15937
+ ...spawnOpts,
15938
+ env
15939
+ });
15755
15940
  }
15756
- (0, import_build_utils3.debug)(
15757
- `Added "${nodeBinPath}" to PATH env because a build command was used.`
15758
- );
15759
- console.log(`Running "${buildCommand}"`);
15760
- await (0, import_build_utils3.execCommand)(buildCommand, {
15761
- ...spawnOpts,
15762
- cwd: entryPath,
15763
- env
15764
- });
15765
- } else if (buildScriptName) {
15766
- await (0, import_build_utils3.runPackageJsonScript)(entryPath, buildScriptName, {
15767
- ...spawnOpts,
15768
- env
15769
- });
15770
- }
15941
+ });
15771
15942
  (0, import_build_utils3.debug)("build command exited");
15772
15943
  if (buildCallback) {
15773
15944
  await buildCallback(buildOptions);
@@ -16419,6 +16590,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16419
16590
  experimentalPPRRoutes.add(route);
16420
16591
  }
16421
16592
  const isAppPPREnabled = requiredServerFilesManifest ? requiredServerFilesManifest.config.experimental?.ppr === true || requiredServerFilesManifest.config.experimental?.ppr === "incremental" : false;
16593
+ const isAppClientSegmentCacheEnabled = requiredServerFilesManifest ? requiredServerFilesManifest.config.experimental?.clientSegmentCache === true : false;
16422
16594
  if (requiredServerFilesManifest) {
16423
16595
  if (!routesManifest) {
16424
16596
  throw new Error(
@@ -16467,7 +16639,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16467
16639
  hasIsr500Page,
16468
16640
  variantsManifest,
16469
16641
  experimentalPPRRoutes,
16470
- isAppPPREnabled
16642
+ isAppPPREnabled,
16643
+ isAppClientSegmentCacheEnabled
16471
16644
  });
16472
16645
  }
16473
16646
  const pageKeys = Object.keys(pages);
@@ -16863,7 +17036,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16863
17036
  canUsePreviewMode,
16864
17037
  bypassToken: prerenderManifest.bypassToken || "",
16865
17038
  isServerMode,
16866
- isAppPPREnabled: false
17039
+ isAppPPREnabled: false,
17040
+ isAppClientSegmentCacheEnabled: false
16867
17041
  }).then(
16868
17042
  (arr) => localizeDynamicRoutes(
16869
17043
  arr,
@@ -16889,7 +17063,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16889
17063
  canUsePreviewMode,
16890
17064
  bypassToken: prerenderManifest.bypassToken || "",
16891
17065
  isServerMode,
16892
- isAppPPREnabled: false
17066
+ isAppPPREnabled: false,
17067
+ isAppClientSegmentCacheEnabled: false
16893
17068
  }).then(
16894
17069
  (arr) => arr.map((route) => {
16895
17070
  route.src = route.src.replace("^", `^${dynamicPrefix}`);
@@ -17068,7 +17243,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17068
17243
  appPathRoutesManifest,
17069
17244
  isSharedLambdas,
17070
17245
  canUsePreviewMode,
17071
- isAppPPREnabled: false
17246
+ isAppPPREnabled: false,
17247
+ isAppClientSegmentCacheEnabled: false
17072
17248
  });
17073
17249
  await Promise.all(
17074
17250
  Object.keys(prerenderManifest.staticRoutes).map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -30,8 +30,8 @@
30
30
  "@types/semver": "6.0.0",
31
31
  "@types/text-table": "0.2.1",
32
32
  "@types/webpack-sources": "3.2.0",
33
- "@vercel/build-utils": "9.2.0",
34
- "@vercel/routing-utils": "5.0.3",
33
+ "@vercel/build-utils": "9.3.0",
34
+ "@vercel/routing-utils": "5.0.4",
35
35
  "async-sema": "3.0.1",
36
36
  "buffer-crc32": "0.2.13",
37
37
  "bytes": "3.1.2",