@vercel/next 4.2.0 → 4.2.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.
Files changed (2) hide show
  1. package/dist/index.js +141 -78
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9408,7 +9408,6 @@ var import_buffer_crc32 = __toESM(require_buffer_crc32());
9408
9408
  var import_fs_extra3 = __toESM(require_lib2());
9409
9409
  var import_path2 = __toESM(require("path"));
9410
9410
  var import_semver = __toESM(require_semver());
9411
- var import_zlib2 = __toESM(require("zlib"));
9412
9411
  var import_url = __toESM(require("url"));
9413
9412
  var import_module = require("module");
9414
9413
  var import_escape_string_regexp = __toESM(require_escape_string_regexp());
@@ -9485,9 +9484,8 @@ var import_path = require("path");
9485
9484
  var KIB = 1024;
9486
9485
  var MIB = 1024 * KIB;
9487
9486
  var EDGE_FUNCTION_SIZE_LIMIT = 4 * MIB;
9488
- var MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * MIB;
9489
- var LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 2.5 * MIB;
9490
- var LAMBDA_RESERVED_COMPRESSED_SIZE = 250 * KIB;
9487
+ var DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * MIB;
9488
+ var LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 25 * MIB;
9491
9489
 
9492
9490
  // src/edge-function-source/get-edge-function-source.ts
9493
9491
  var import_zlib = __toESM(require("zlib"));
@@ -9554,6 +9552,9 @@ async function validateSize(script, wasmFiles) {
9554
9552
  var require_ = (0, import_module.createRequire)(__filename);
9555
9553
  var RSC_CONTENT_TYPE = "x-component";
9556
9554
  var RSC_PREFETCH_SUFFIX = ".prefetch.rsc";
9555
+ var MAX_UNCOMPRESSED_LAMBDA_SIZE = !isNaN(
9556
+ Number(process.env.MAX_UNCOMPRESSED_LAMBDA_SIZE)
9557
+ ) ? Number(process.env.MAX_UNCOMPRESSED_LAMBDA_SIZE) : DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE;
9557
9558
  var TEST_DYNAMIC_ROUTE = /\/\[[^\/]+?\](?=\/|$)/;
9558
9559
  function isDynamicRoute(route) {
9559
9560
  route = route.startsWith("/") ? route : `/${route}`;
@@ -9764,6 +9765,14 @@ async function getDynamicRoutes({
9764
9765
  ),
9765
9766
  dest: route.dest?.replace(/($|\?)/, ".rsc$1")
9766
9767
  });
9768
+ routes2.push({
9769
+ ...route,
9770
+ src: route.src.replace(
9771
+ new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
9772
+ "(?:\\.action)(?:/)?$"
9773
+ ),
9774
+ dest: route.dest?.replace(/($|\?)/, ".action$1")
9775
+ });
9767
9776
  routes2.push(route);
9768
9777
  }
9769
9778
  return routes2;
@@ -9937,19 +9946,6 @@ var collectTracedFiles = (baseDir, lstatResults, lstatSema, reasons, files) => a
9937
9946
  });
9938
9947
  };
9939
9948
  var ExperimentalTraceVersion = `9.0.4-canary.1`;
9940
- var compressBuffer = (buf) => {
9941
- return new Promise((resolve, reject) => {
9942
- import_zlib2.default.deflateRaw(
9943
- buf,
9944
- { level: import_zlib2.default.constants.Z_BEST_COMPRESSION },
9945
- (err, compBuf) => {
9946
- if (err)
9947
- return reject(err);
9948
- resolve(compBuf);
9949
- }
9950
- );
9951
- });
9952
- };
9953
9949
  async function createPseudoLayer(files) {
9954
9950
  const pseudoLayer = {};
9955
9951
  let pseudoLayerBytes = 0;
@@ -9964,11 +9960,9 @@ async function createPseudoLayer(files) {
9964
9960
  };
9965
9961
  } else {
9966
9962
  const origBuffer = await (0, import_build_utils.streamToBuffer)(file.toStream());
9967
- const compBuffer = await compressBuffer(origBuffer);
9968
- pseudoLayerBytes += compBuffer.byteLength;
9963
+ pseudoLayerBytes += origBuffer.byteLength;
9969
9964
  pseudoLayer[fileName] = {
9970
9965
  file,
9971
- compBuffer,
9972
9966
  isSymlink: false,
9973
9967
  crc32: import_buffer_crc32.default.unsigned(origBuffer),
9974
9968
  uncompressedSize: origBuffer.byteLength
@@ -10376,7 +10370,6 @@ async function getPageLambdaGroups({
10376
10370
  tracedPseudoLayer,
10377
10371
  initialPseudoLayer,
10378
10372
  initialPseudoLayerUncompressed,
10379
- lambdaCompressedByteLimit,
10380
10373
  internalPages,
10381
10374
  pageExtensions,
10382
10375
  inversedAppPathManifest,
@@ -10410,22 +10403,18 @@ async function getPageLambdaGroups({
10410
10403
  let matchingGroup = experimentalAllowBundling ? void 0 : groups.find((group) => {
10411
10404
  const matches = group.maxDuration === opts.maxDuration && group.memory === opts.memory && group.isPrerenders === isPrerenderRoute && group.isExperimentalPPR === isExperimentalPPR;
10412
10405
  if (matches) {
10413
- let newTracedFilesSize = group.pseudoLayerBytes;
10414
10406
  let newTracedFilesUncompressedSize = group.pseudoLayerUncompressedBytes;
10415
10407
  for (const newPage of newPages) {
10416
10408
  Object.keys(pageTraces[newPage] || {}).map((file) => {
10417
10409
  if (!group.pseudoLayer[file]) {
10418
10410
  const item = tracedPseudoLayer[file];
10419
- newTracedFilesSize += item.compBuffer?.byteLength || 0;
10420
10411
  newTracedFilesUncompressedSize += item.uncompressedSize || 0;
10421
10412
  }
10422
10413
  });
10423
- newTracedFilesSize += compressedPages[newPage].compBuffer.byteLength;
10424
10414
  newTracedFilesUncompressedSize += compressedPages[newPage].uncompressedSize;
10425
10415
  }
10426
10416
  const underUncompressedLimit = newTracedFilesUncompressedSize < MAX_UNCOMPRESSED_LAMBDA_SIZE - LAMBDA_RESERVED_UNCOMPRESSED_SIZE;
10427
- const underCompressedLimit = newTracedFilesSize < lambdaCompressedByteLimit - LAMBDA_RESERVED_COMPRESSED_SIZE;
10428
- return underUncompressedLimit && underCompressedLimit;
10417
+ return underUncompressedLimit;
10429
10418
  }
10430
10419
  return false;
10431
10420
  });
@@ -10448,31 +10437,24 @@ async function getPageLambdaGroups({
10448
10437
  for (const newPage of newPages) {
10449
10438
  Object.keys(pageTraces[newPage] || {}).map((file) => {
10450
10439
  const pseudoItem = tracedPseudoLayer[file];
10451
- const compressedSize = pseudoItem?.compBuffer?.byteLength || 0;
10452
10440
  if (!matchingGroup.pseudoLayer[file]) {
10453
10441
  matchingGroup.pseudoLayer[file] = pseudoItem;
10454
- matchingGroup.pseudoLayerBytes += compressedSize;
10455
10442
  matchingGroup.pseudoLayerUncompressedBytes += pseudoItem.uncompressedSize || 0;
10456
10443
  }
10457
10444
  });
10458
- matchingGroup.pseudoLayerBytes += compressedPages[newPage].compBuffer.byteLength;
10459
10445
  matchingGroup.pseudoLayerUncompressedBytes += compressedPages[newPage].uncompressedSize;
10460
10446
  }
10461
10447
  }
10462
10448
  return groups;
10463
10449
  }
10464
- var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLayerUncompressedBytes, compressedPages) => {
10450
+ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerUncompressedBytes, compressedPages) => {
10465
10451
  const exceededLimitOutput = [];
10466
10452
  console.log(
10467
10453
  `Serverless Function's page${pages.length === 1 ? "" : "s"}: ${pages.join(
10468
10454
  ", "
10469
10455
  )}`
10470
10456
  );
10471
- exceededLimitOutput.push([
10472
- "Large Dependencies",
10473
- "Uncompressed size",
10474
- "Compressed size"
10475
- ]);
10457
+ exceededLimitOutput.push(["Large Dependencies", "Uncompressed size"]);
10476
10458
  const dependencies = {};
10477
10459
  for (const fileKey of Object.keys(pseudoLayer)) {
10478
10460
  if (!pseudoLayer[fileKey].isSymlink) {
@@ -10480,17 +10462,14 @@ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLa
10480
10462
  const depKey = fileKey.split("/").slice(0, 3).join("/");
10481
10463
  if (!dependencies[depKey]) {
10482
10464
  dependencies[depKey] = {
10483
- compressed: 0,
10484
10465
  uncompressed: 0
10485
10466
  };
10486
10467
  }
10487
- dependencies[depKey].compressed += fileItem.compBuffer.byteLength;
10488
10468
  dependencies[depKey].uncompressed += fileItem.uncompressedSize;
10489
10469
  }
10490
10470
  }
10491
10471
  for (const page of pages) {
10492
10472
  dependencies[`pages/${page}`] = {
10493
- compressed: compressedPages[page].compBuffer.byteLength,
10494
10473
  uncompressed: compressedPages[page].uncompressedSize
10495
10474
  };
10496
10475
  }
@@ -10498,51 +10477,45 @@ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLa
10498
10477
  Object.keys(dependencies).sort((a, b) => {
10499
10478
  const aDep = dependencies[a];
10500
10479
  const bDep = dependencies[b];
10501
- if (aDep.compressed > bDep.compressed) {
10480
+ if (aDep.uncompressed > bDep.uncompressed) {
10502
10481
  return -1;
10503
10482
  }
10504
- if (aDep.compressed < bDep.compressed) {
10483
+ if (aDep.uncompressed < bDep.uncompressed) {
10505
10484
  return 1;
10506
10485
  }
10507
10486
  return 0;
10508
10487
  }).forEach((depKey) => {
10509
10488
  const dep = dependencies[depKey];
10510
- if (dep.compressed < 100 * KIB && dep.uncompressed < 500 * KIB) {
10489
+ if (dep.uncompressed < 500 * KIB) {
10511
10490
  return;
10512
10491
  }
10513
- exceededLimitOutput.push([
10514
- depKey,
10515
- prettyBytes(dep.uncompressed),
10516
- prettyBytes(dep.compressed)
10517
- ]);
10492
+ exceededLimitOutput.push([depKey, prettyBytes(dep.uncompressed)]);
10518
10493
  numLargeDependencies += 1;
10519
10494
  });
10520
10495
  if (numLargeDependencies === 0) {
10521
10496
  exceededLimitOutput.push([
10522
- "No large dependencies found (> 100KB compressed)"
10497
+ "No large dependencies found (> 500KB compressed)"
10523
10498
  ]);
10524
10499
  }
10525
10500
  exceededLimitOutput.push([]);
10526
10501
  exceededLimitOutput.push([
10527
10502
  "All dependencies",
10528
- prettyBytes(pseudoLayerUncompressedBytes),
10529
- prettyBytes(pseudoLayerBytes)
10503
+ prettyBytes(pseudoLayerUncompressedBytes)
10530
10504
  ]);
10531
10505
  console.log(
10532
10506
  (0, import_text_table.default)(exceededLimitOutput, {
10533
- align: ["l", "r", "r"]
10507
+ align: ["l", "r"]
10534
10508
  })
10535
10509
  );
10536
10510
  };
10537
- var detectLambdaLimitExceeding = async (lambdaGroups, compressedSizeLimit, compressedPages) => {
10538
- const COMPRESSED_SIZE_LIMIT_CLOSE = compressedSizeLimit - 5 * MIB;
10511
+ var detectLambdaLimitExceeding = async (lambdaGroups, compressedPages) => {
10539
10512
  const UNCOMPRESSED_SIZE_LIMIT_CLOSE = MAX_UNCOMPRESSED_LAMBDA_SIZE - 5 * MIB;
10540
10513
  let numExceededLimit = 0;
10541
10514
  let numCloseToLimit = 0;
10542
10515
  let loggedHeadInfo = false;
10543
10516
  const filteredGroups = lambdaGroups.filter((group) => {
10544
- const exceededLimit = group.pseudoLayerBytes > compressedSizeLimit || group.pseudoLayerUncompressedBytes > MAX_UNCOMPRESSED_LAMBDA_SIZE;
10545
- const closeToLimit = group.pseudoLayerBytes > COMPRESSED_SIZE_LIMIT_CLOSE || group.pseudoLayerUncompressedBytes > UNCOMPRESSED_SIZE_LIMIT_CLOSE;
10517
+ const exceededLimit = group.pseudoLayerUncompressedBytes > MAX_UNCOMPRESSED_LAMBDA_SIZE;
10518
+ const closeToLimit = group.pseudoLayerUncompressedBytes > UNCOMPRESSED_SIZE_LIMIT_CLOSE;
10546
10519
  if (closeToLimit || exceededLimit || (0, import_build_utils.getPlatformEnv)("BUILDER_DEBUG") || process.env.NEXT_DEBUG_FUNCTION_SIZE) {
10547
10520
  if (exceededLimit) {
10548
10521
  numExceededLimit += 1;
@@ -10558,8 +10531,6 @@ var detectLambdaLimitExceeding = async (lambdaGroups, compressedSizeLimit, compr
10558
10531
  if (numExceededLimit || numCloseToLimit) {
10559
10532
  console.log(
10560
10533
  `Warning: Max serverless function size of ${prettyBytes(
10561
- compressedSizeLimit
10562
- )} compressed or ${prettyBytes(
10563
10534
  MAX_UNCOMPRESSED_LAMBDA_SIZE
10564
10535
  )} uncompressed${numExceededLimit ? "" : " almost"} reached`
10565
10536
  );
@@ -10571,7 +10542,6 @@ var detectLambdaLimitExceeding = async (lambdaGroups, compressedSizeLimit, compr
10571
10542
  outputFunctionFileSizeInfo(
10572
10543
  group.pages,
10573
10544
  group.pseudoLayer,
10574
- group.pseudoLayerBytes,
10575
10545
  group.pseudoLayerUncompressedBytes,
10576
10546
  compressedPages
10577
10547
  );
@@ -12019,6 +11989,7 @@ var CORRECT_NOT_FOUND_ROUTES_VERSION = "v12.0.1";
12019
11989
  var CORRECT_MIDDLEWARE_ORDER_VERSION = "v12.1.7-canary.29";
12020
11990
  var NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = "v12.1.7-canary.33";
12021
11991
  var EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = "v12.2.0";
11992
+ var ACTION_OUTPUT_SUPPORT_VERSION = "v14.2.2";
12022
11993
  var CORRECTED_MANIFESTS_VERSION = "v12.2.0";
12023
11994
  var PRELOAD_CHUNKS = {
12024
11995
  APP_ROUTER_PAGES: [
@@ -12081,7 +12052,6 @@ async function serverBuild({
12081
12052
  omittedPrerenderRoutes,
12082
12053
  trailingSlashRedirects,
12083
12054
  isCorrectLocaleAPIRoutes,
12084
- lambdaCompressedByteLimit,
12085
12055
  requiredServerFilesManifest,
12086
12056
  variantsManifest,
12087
12057
  experimentalPPRRoutes
@@ -12099,6 +12069,10 @@ async function serverBuild({
12099
12069
  nextVersion,
12100
12070
  EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION
12101
12071
  );
12072
+ const hasActionOutputSupport = import_semver3.default.gte(
12073
+ nextVersion,
12074
+ ACTION_OUTPUT_SUPPORT_VERSION
12075
+ );
12102
12076
  const projectDir = requiredServerFilesManifest.relativeAppDir ? import_path4.default.join(baseDir, requiredServerFilesManifest.relativeAppDir) : requiredServerFilesManifest.appDir || entryPath;
12103
12077
  const inversedAppPathManifest = {};
12104
12078
  if (appPathRoutesManifest) {
@@ -12423,23 +12397,20 @@ async function serverBuild({
12423
12397
  2
12424
12398
  )
12425
12399
  );
12426
- if (initialPseudoLayer.pseudoLayerBytes > lambdaCompressedByteLimit || uncompressedInitialSize > MAX_UNCOMPRESSED_LAMBDA_SIZE) {
12400
+ if (uncompressedInitialSize > MAX_UNCOMPRESSED_LAMBDA_SIZE) {
12427
12401
  console.log(
12428
12402
  `Warning: Max serverless function size of ${(0, import_pretty_bytes3.default)(
12429
- lambdaCompressedByteLimit
12430
- )} compressed or ${(0, import_pretty_bytes3.default)(
12431
12403
  MAX_UNCOMPRESSED_LAMBDA_SIZE
12432
12404
  )} uncompressed reached`
12433
12405
  );
12434
12406
  outputFunctionFileSizeInfo(
12435
12407
  [],
12436
12408
  initialPseudoLayer.pseudoLayer,
12437
- initialPseudoLayer.pseudoLayerBytes,
12438
12409
  uncompressedInitialSize,
12439
12410
  {}
12440
12411
  );
12441
12412
  throw new import_build_utils2.NowBuildError({
12442
- message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${lambdaCompressedByteLimit} bytes`,
12413
+ message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${MAX_UNCOMPRESSED_LAMBDA_SIZE} bytes`,
12443
12414
  code: "NEXT_REQUIRED_FILES_LIMIT",
12444
12415
  link: "https://vercel.com/docs/platform/limits#serverless-function-size"
12445
12416
  });
@@ -12601,7 +12572,6 @@ async function serverBuild({
12601
12572
  experimentalPPRRoutes: void 0,
12602
12573
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12603
12574
  initialPseudoLayer,
12604
- lambdaCompressedByteLimit,
12605
12575
  initialPseudoLayerUncompressed: uncompressedInitialSize,
12606
12576
  internalPages,
12607
12577
  pageExtensions
@@ -12621,7 +12591,6 @@ async function serverBuild({
12621
12591
  experimentalPPRRoutes,
12622
12592
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12623
12593
  initialPseudoLayer,
12624
- lambdaCompressedByteLimit,
12625
12594
  initialPseudoLayerUncompressed: uncompressedInitialSize,
12626
12595
  internalPages,
12627
12596
  pageExtensions,
@@ -12639,17 +12608,24 @@ async function serverBuild({
12639
12608
  experimentalPPRRoutes: void 0,
12640
12609
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12641
12610
  initialPseudoLayer,
12642
- lambdaCompressedByteLimit,
12643
12611
  initialPseudoLayerUncompressed: uncompressedInitialSize,
12644
12612
  internalPages,
12645
12613
  pageExtensions,
12646
12614
  inversedAppPathManifest
12647
12615
  });
12616
+ const appRouterStreamingPrerenderLambdaGroups = [];
12648
12617
  for (const group of appRouterLambdaGroups) {
12649
12618
  if (!group.isPrerenders || group.isExperimentalPPR) {
12650
12619
  group.isStreaming = true;
12651
12620
  }
12652
12621
  group.isAppRouter = true;
12622
+ if (hasActionOutputSupport && group.isPrerenders && !group.isStreaming && !group.isExperimentalPPR) {
12623
+ appRouterStreamingPrerenderLambdaGroups.push({
12624
+ ...group,
12625
+ isActionPrerender: true,
12626
+ isStreaming: true
12627
+ });
12628
+ }
12653
12629
  }
12654
12630
  for (const group of appRouteHandlersLambdaGroups) {
12655
12631
  if (!group.isPrerenders) {
@@ -12670,7 +12646,6 @@ async function serverBuild({
12670
12646
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12671
12647
  initialPseudoLayer,
12672
12648
  initialPseudoLayerUncompressed: uncompressedInitialSize,
12673
- lambdaCompressedByteLimit,
12674
12649
  internalPages,
12675
12650
  pageExtensions
12676
12651
  });
@@ -12698,6 +12673,12 @@ async function serverBuild({
12698
12673
  pseudoLayerBytes: group.pseudoLayerBytes,
12699
12674
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
12700
12675
  })),
12676
+ appRouterStreamingPrerenderLambdaGroups: appRouterStreamingPrerenderLambdaGroups.map((group) => ({
12677
+ pages: group.pages,
12678
+ isPrerender: group.isPrerenders,
12679
+ pseudoLayerBytes: group.pseudoLayerBytes,
12680
+ uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
12681
+ })),
12701
12682
  appRouteHandlersLambdaGroups: appRouteHandlersLambdaGroups.map(
12702
12683
  (group) => ({
12703
12684
  pages: group.pages,
@@ -12715,17 +12696,20 @@ async function serverBuild({
12715
12696
  const combinedGroups = [
12716
12697
  ...pageLambdaGroups,
12717
12698
  ...appRouterLambdaGroups,
12699
+ ...appRouterStreamingPrerenderLambdaGroups,
12718
12700
  ...apiLambdaGroups,
12719
12701
  ...appRouteHandlersLambdaGroups
12720
12702
  ];
12721
- await detectLambdaLimitExceeding(
12722
- combinedGroups,
12723
- lambdaCompressedByteLimit,
12724
- compressedPages
12725
- );
12703
+ await detectLambdaLimitExceeding(combinedGroups, compressedPages);
12704
+ const appNotFoundTraces = pageTraces["_not-found.js"];
12705
+ const appNotFoundPsuedoLayer = appNotFoundTraces && await createPseudoLayer(appNotFoundTraces);
12726
12706
  for (const group of combinedGroups) {
12727
12707
  const groupPageFiles = {};
12728
- for (const page of [...group.pages, ...internalPages]) {
12708
+ for (const page of [
12709
+ ...group.pages,
12710
+ ...internalPages,
12711
+ ...group.isAppRouter && appNotFoundTraces ? ["_not-found.js"] : []
12712
+ ]) {
12729
12713
  const pageFileName = import_path4.default.normalize(
12730
12714
  import_path4.default.relative(baseDir, lambdaPages[page].fsPath)
12731
12715
  );
@@ -12831,6 +12815,9 @@ async function serverBuild({
12831
12815
  nextVersion,
12832
12816
  experimentalAllowBundling
12833
12817
  };
12818
+ if (group.isAppRouter && appNotFoundPsuedoLayer) {
12819
+ options.layers.push(appNotFoundPsuedoLayer.pseudoLayer);
12820
+ }
12834
12821
  const lambda = await createLambdaFromPseudoLayers(options);
12835
12822
  const isPPR = experimental.ppr && group.isAppRouter && !group.isAppRouteHandler;
12836
12823
  let revalidate;
@@ -12856,6 +12843,9 @@ async function serverBuild({
12856
12843
  });
12857
12844
  }
12858
12845
  let outputName = import_path4.default.posix.join(entryDirectory, pageName);
12846
+ if (group.isActionPrerender) {
12847
+ outputName = `${outputName}.action`;
12848
+ }
12859
12849
  if (isPPR) {
12860
12850
  if (!revalidate) {
12861
12851
  throw new Error("Invariant: PPR lambda isn't set");
@@ -13395,6 +13385,70 @@ async function serverBuild({
13395
13385
  override: true
13396
13386
  }
13397
13387
  ] : [],
13388
+ ...hasActionOutputSupport ? [
13389
+ // Create rewrites for streaming prerenders (.action routes)
13390
+ // This contains separate rewrites for each possible "has" (action header, or content-type)
13391
+ // Also includes separate handling for index routes which should match to /index.action.
13392
+ // This follows the same pattern as the rewrites for .rsc files.
13393
+ {
13394
+ src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
13395
+ dest: import_path4.default.posix.join("/", entryDirectory, "/index.action"),
13396
+ has: [
13397
+ {
13398
+ type: "header",
13399
+ key: "next-action"
13400
+ }
13401
+ ],
13402
+ continue: true,
13403
+ override: true
13404
+ },
13405
+ {
13406
+ src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
13407
+ dest: import_path4.default.posix.join("/", entryDirectory, "/index.action"),
13408
+ has: [
13409
+ {
13410
+ type: "header",
13411
+ key: "content-type",
13412
+ value: "multipart/form-data;.*"
13413
+ }
13414
+ ],
13415
+ continue: true,
13416
+ override: true
13417
+ },
13418
+ {
13419
+ src: `^${import_path4.default.posix.join(
13420
+ "/",
13421
+ entryDirectory,
13422
+ "/((?!.+\\.action).+?)(?:/)?$"
13423
+ )}`,
13424
+ dest: import_path4.default.posix.join("/", entryDirectory, "/$1.action"),
13425
+ has: [
13426
+ {
13427
+ type: "header",
13428
+ key: "next-action"
13429
+ }
13430
+ ],
13431
+ continue: true,
13432
+ override: true
13433
+ },
13434
+ {
13435
+ src: `^${import_path4.default.posix.join(
13436
+ "/",
13437
+ entryDirectory,
13438
+ "/((?!.+\\.action).+?)(?:/)?$"
13439
+ )}`,
13440
+ dest: import_path4.default.posix.join("/", entryDirectory, "/$1.action"),
13441
+ has: [
13442
+ {
13443
+ type: "header",
13444
+ key: "content-type",
13445
+ value: "multipart/form-data;.*"
13446
+ }
13447
+ ],
13448
+ continue: true,
13449
+ override: true
13450
+ }
13451
+ ] : [],
13398
13452
  {
13399
13453
  src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
13400
13454
  has: [
@@ -13827,7 +13881,6 @@ var build = async ({
13827
13881
  meta = {}
13828
13882
  }) => {
13829
13883
  validateEntrypoint(entrypoint);
13830
- const lambdaCompressedByteLimit = config.maxLambdaSize || 50 * MIB;
13831
13884
  let entryDirectory = import_path5.default.dirname(entrypoint);
13832
13885
  let entryPath = import_path5.default.join(workPath, entryDirectory);
13833
13886
  if (config.rootDirectory) {
@@ -13932,6 +13985,20 @@ var build = async ({
13932
13985
  } else {
13933
13986
  await (0, import_build_utils3.runNpmInstall)(entryPath, [], spawnOpts, meta, nodeVersion);
13934
13987
  }
13988
+ if (spawnOpts.env.VERCEL_ANALYTICS_ID) {
13989
+ (0, import_build_utils3.debug)("Found VERCEL_ANALYTICS_ID in environment");
13990
+ const version2 = await (0, import_build_utils3.getInstalledPackageVersion)(
13991
+ "@vercel/speed-insights",
13992
+ entryPath
13993
+ );
13994
+ if (version2) {
13995
+ delete spawnOpts.env.VERCEL_ANALYTICS_ID;
13996
+ delete process.env.VERCEL_ANALYTICS_ID;
13997
+ (0, import_build_utils3.debug)(
13998
+ "@vercel/speed-insights is installed, removing VERCEL_ANALYTICS_ID from environment"
13999
+ );
14000
+ }
14001
+ }
13935
14002
  const nextVersion = getRealNextVersion(entryPath);
13936
14003
  if (!nextVersion) {
13937
14004
  throw new import_build_utils3.NowBuildError({
@@ -14686,7 +14753,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14686
14753
  escapedBuildId,
14687
14754
  outputDirectory,
14688
14755
  trailingSlashRedirects,
14689
- lambdaCompressedByteLimit,
14690
14756
  requiredServerFilesManifest,
14691
14757
  privateOutputs,
14692
14758
  hasIsr404Page,
@@ -14858,7 +14924,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14858
14924
  tracedPseudoLayer: tracedPseudoLayer?.pseudoLayer || {},
14859
14925
  initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
14860
14926
  initialPseudoLayerUncompressed: 0,
14861
- lambdaCompressedByteLimit,
14862
14927
  // internal pages are already referenced in traces for serverless
14863
14928
  // like builds
14864
14929
  internalPages: [],
@@ -14875,7 +14940,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14875
14940
  tracedPseudoLayer: tracedPseudoLayer?.pseudoLayer || {},
14876
14941
  initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
14877
14942
  initialPseudoLayerUncompressed: 0,
14878
- lambdaCompressedByteLimit,
14879
14943
  internalPages: [],
14880
14944
  experimentalPPRRoutes: void 0
14881
14945
  });
@@ -14906,7 +14970,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14906
14970
  ];
14907
14971
  await detectLambdaLimitExceeding(
14908
14972
  combinedInitialLambdaGroups,
14909
- lambdaCompressedByteLimit,
14910
14973
  compressedPages
14911
14974
  );
14912
14975
  let apiLambdaGroupIndex = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",