@vercel/next 4.0.7 → 4.0.9

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/index.js CHANGED
@@ -837,7 +837,7 @@ var require_lib = __commonJS({
837
837
  function defaultInit() {
838
838
  return "1";
839
839
  }
840
- var Sema4 = class {
840
+ var Sema3 = class {
841
841
  constructor(nr, { initFn = defaultInit, pauseFn, resumeFn, capacity = 10 } = {}) {
842
842
  if (isFn(pauseFn) !== isFn(resumeFn)) {
843
843
  throw new Error("pauseFn and resumeFn must be both set for pausing");
@@ -893,9 +893,9 @@ var require_lib = __commonJS({
893
893
  return this.waiting.length;
894
894
  }
895
895
  };
896
- exports.Sema = Sema4;
896
+ exports.Sema = Sema3;
897
897
  function RateLimit(rps, { timeUnit = 1e3, uniformDistribution = false } = {}) {
898
- const sema = new Sema4(uniformDistribution ? 1 : rps);
898
+ const sema = new Sema3(uniformDistribution ? 1 : rps);
899
899
  const delay = uniformDistribution ? timeUnit / rps : timeUnit;
900
900
  return async function rl() {
901
901
  await sema.acquire();
@@ -5870,313 +5870,6 @@ var require_semver = __commonJS({
5870
5870
  }
5871
5871
  });
5872
5872
 
5873
- // ../../node_modules/.pnpm/buffer-crc32@0.2.13/node_modules/buffer-crc32/index.js
5874
- var require_buffer_crc32 = __commonJS({
5875
- "../../node_modules/.pnpm/buffer-crc32@0.2.13/node_modules/buffer-crc32/index.js"(exports, module2) {
5876
- var Buffer2 = require("buffer").Buffer;
5877
- var CRC_TABLE = [
5878
- 0,
5879
- 1996959894,
5880
- 3993919788,
5881
- 2567524794,
5882
- 124634137,
5883
- 1886057615,
5884
- 3915621685,
5885
- 2657392035,
5886
- 249268274,
5887
- 2044508324,
5888
- 3772115230,
5889
- 2547177864,
5890
- 162941995,
5891
- 2125561021,
5892
- 3887607047,
5893
- 2428444049,
5894
- 498536548,
5895
- 1789927666,
5896
- 4089016648,
5897
- 2227061214,
5898
- 450548861,
5899
- 1843258603,
5900
- 4107580753,
5901
- 2211677639,
5902
- 325883990,
5903
- 1684777152,
5904
- 4251122042,
5905
- 2321926636,
5906
- 335633487,
5907
- 1661365465,
5908
- 4195302755,
5909
- 2366115317,
5910
- 997073096,
5911
- 1281953886,
5912
- 3579855332,
5913
- 2724688242,
5914
- 1006888145,
5915
- 1258607687,
5916
- 3524101629,
5917
- 2768942443,
5918
- 901097722,
5919
- 1119000684,
5920
- 3686517206,
5921
- 2898065728,
5922
- 853044451,
5923
- 1172266101,
5924
- 3705015759,
5925
- 2882616665,
5926
- 651767980,
5927
- 1373503546,
5928
- 3369554304,
5929
- 3218104598,
5930
- 565507253,
5931
- 1454621731,
5932
- 3485111705,
5933
- 3099436303,
5934
- 671266974,
5935
- 1594198024,
5936
- 3322730930,
5937
- 2970347812,
5938
- 795835527,
5939
- 1483230225,
5940
- 3244367275,
5941
- 3060149565,
5942
- 1994146192,
5943
- 31158534,
5944
- 2563907772,
5945
- 4023717930,
5946
- 1907459465,
5947
- 112637215,
5948
- 2680153253,
5949
- 3904427059,
5950
- 2013776290,
5951
- 251722036,
5952
- 2517215374,
5953
- 3775830040,
5954
- 2137656763,
5955
- 141376813,
5956
- 2439277719,
5957
- 3865271297,
5958
- 1802195444,
5959
- 476864866,
5960
- 2238001368,
5961
- 4066508878,
5962
- 1812370925,
5963
- 453092731,
5964
- 2181625025,
5965
- 4111451223,
5966
- 1706088902,
5967
- 314042704,
5968
- 2344532202,
5969
- 4240017532,
5970
- 1658658271,
5971
- 366619977,
5972
- 2362670323,
5973
- 4224994405,
5974
- 1303535960,
5975
- 984961486,
5976
- 2747007092,
5977
- 3569037538,
5978
- 1256170817,
5979
- 1037604311,
5980
- 2765210733,
5981
- 3554079995,
5982
- 1131014506,
5983
- 879679996,
5984
- 2909243462,
5985
- 3663771856,
5986
- 1141124467,
5987
- 855842277,
5988
- 2852801631,
5989
- 3708648649,
5990
- 1342533948,
5991
- 654459306,
5992
- 3188396048,
5993
- 3373015174,
5994
- 1466479909,
5995
- 544179635,
5996
- 3110523913,
5997
- 3462522015,
5998
- 1591671054,
5999
- 702138776,
6000
- 2966460450,
6001
- 3352799412,
6002
- 1504918807,
6003
- 783551873,
6004
- 3082640443,
6005
- 3233442989,
6006
- 3988292384,
6007
- 2596254646,
6008
- 62317068,
6009
- 1957810842,
6010
- 3939845945,
6011
- 2647816111,
6012
- 81470997,
6013
- 1943803523,
6014
- 3814918930,
6015
- 2489596804,
6016
- 225274430,
6017
- 2053790376,
6018
- 3826175755,
6019
- 2466906013,
6020
- 167816743,
6021
- 2097651377,
6022
- 4027552580,
6023
- 2265490386,
6024
- 503444072,
6025
- 1762050814,
6026
- 4150417245,
6027
- 2154129355,
6028
- 426522225,
6029
- 1852507879,
6030
- 4275313526,
6031
- 2312317920,
6032
- 282753626,
6033
- 1742555852,
6034
- 4189708143,
6035
- 2394877945,
6036
- 397917763,
6037
- 1622183637,
6038
- 3604390888,
6039
- 2714866558,
6040
- 953729732,
6041
- 1340076626,
6042
- 3518719985,
6043
- 2797360999,
6044
- 1068828381,
6045
- 1219638859,
6046
- 3624741850,
6047
- 2936675148,
6048
- 906185462,
6049
- 1090812512,
6050
- 3747672003,
6051
- 2825379669,
6052
- 829329135,
6053
- 1181335161,
6054
- 3412177804,
6055
- 3160834842,
6056
- 628085408,
6057
- 1382605366,
6058
- 3423369109,
6059
- 3138078467,
6060
- 570562233,
6061
- 1426400815,
6062
- 3317316542,
6063
- 2998733608,
6064
- 733239954,
6065
- 1555261956,
6066
- 3268935591,
6067
- 3050360625,
6068
- 752459403,
6069
- 1541320221,
6070
- 2607071920,
6071
- 3965973030,
6072
- 1969922972,
6073
- 40735498,
6074
- 2617837225,
6075
- 3943577151,
6076
- 1913087877,
6077
- 83908371,
6078
- 2512341634,
6079
- 3803740692,
6080
- 2075208622,
6081
- 213261112,
6082
- 2463272603,
6083
- 3855990285,
6084
- 2094854071,
6085
- 198958881,
6086
- 2262029012,
6087
- 4057260610,
6088
- 1759359992,
6089
- 534414190,
6090
- 2176718541,
6091
- 4139329115,
6092
- 1873836001,
6093
- 414664567,
6094
- 2282248934,
6095
- 4279200368,
6096
- 1711684554,
6097
- 285281116,
6098
- 2405801727,
6099
- 4167216745,
6100
- 1634467795,
6101
- 376229701,
6102
- 2685067896,
6103
- 3608007406,
6104
- 1308918612,
6105
- 956543938,
6106
- 2808555105,
6107
- 3495958263,
6108
- 1231636301,
6109
- 1047427035,
6110
- 2932959818,
6111
- 3654703836,
6112
- 1088359270,
6113
- 936918e3,
6114
- 2847714899,
6115
- 3736837829,
6116
- 1202900863,
6117
- 817233897,
6118
- 3183342108,
6119
- 3401237130,
6120
- 1404277552,
6121
- 615818150,
6122
- 3134207493,
6123
- 3453421203,
6124
- 1423857449,
6125
- 601450431,
6126
- 3009837614,
6127
- 3294710456,
6128
- 1567103746,
6129
- 711928724,
6130
- 3020668471,
6131
- 3272380065,
6132
- 1510334235,
6133
- 755167117
6134
- ];
6135
- if (typeof Int32Array !== "undefined") {
6136
- CRC_TABLE = new Int32Array(CRC_TABLE);
6137
- }
6138
- function ensureBuffer(input) {
6139
- if (Buffer2.isBuffer(input)) {
6140
- return input;
6141
- }
6142
- var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
6143
- if (typeof input === "number") {
6144
- return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
6145
- } else if (typeof input === "string") {
6146
- return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
6147
- } else {
6148
- throw new Error("input must be buffer, number, or string, received " + typeof input);
6149
- }
6150
- }
6151
- function bufferizeInt(num) {
6152
- var tmp = ensureBuffer(4);
6153
- tmp.writeInt32BE(num, 0);
6154
- return tmp;
6155
- }
6156
- function _crc32(buf, previous) {
6157
- buf = ensureBuffer(buf);
6158
- if (Buffer2.isBuffer(previous)) {
6159
- previous = previous.readUInt32BE(0);
6160
- }
6161
- var crc = ~~previous ^ -1;
6162
- for (var n = 0; n < buf.length; n++) {
6163
- crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
6164
- }
6165
- return crc ^ -1;
6166
- }
6167
- function crc322() {
6168
- return bufferizeInt(_crc32.apply(null, arguments));
6169
- }
6170
- crc322.signed = function() {
6171
- return _crc32.apply(null, arguments);
6172
- };
6173
- crc322.unsigned = function() {
6174
- return _crc32.apply(null, arguments) >>> 0;
6175
- };
6176
- module2.exports = crc322;
6177
- }
6178
- });
6179
-
6180
5873
  // ../../node_modules/.pnpm/text-table@0.2.0/node_modules/text-table/index.js
6181
5874
  var require_text_table = __commonJS({
6182
5875
  "../../node_modules/.pnpm/text-table@0.2.0/node_modules/text-table/index.js"(exports, module2) {
@@ -9385,7 +9078,7 @@ module.exports = __toCommonJS(src_exports);
9385
9078
  var import_build_utils3 = require("@vercel/build-utils");
9386
9079
  var import_superstatic = __toESM(require_superstatic());
9387
9080
  var import_nft2 = require("@vercel/nft");
9388
- var import_async_sema3 = __toESM(require_lib());
9081
+ var import_async_sema2 = __toESM(require_lib());
9389
9082
  var import_escape_string_regexp3 = __toESM(require_escape_string_regexp());
9390
9083
  var import_find_up = __toESM(require_find_up());
9391
9084
  var import_fs_extra6 = __toESM(require_lib2());
@@ -9400,12 +9093,9 @@ var import_semver2 = __toESM(require_semver());
9400
9093
 
9401
9094
  // src/utils.ts
9402
9095
  var import_build_utils = require("@vercel/build-utils");
9403
- var import_async_sema = __toESM(require_lib());
9404
- var import_buffer_crc32 = __toESM(require_buffer_crc32());
9405
9096
  var import_fs_extra3 = __toESM(require_lib2());
9406
9097
  var import_path2 = __toESM(require("path"));
9407
9098
  var import_semver = __toESM(require_semver());
9408
- var import_zlib2 = __toESM(require("zlib"));
9409
9099
  var import_url = __toESM(require("url"));
9410
9100
  var import_module = require("module");
9411
9101
  var import_escape_string_regexp = __toESM(require_escape_string_regexp());
@@ -9484,7 +9174,6 @@ var MIB = 1024 * KIB;
9484
9174
  var EDGE_FUNCTION_SIZE_LIMIT = 4 * MIB;
9485
9175
  var MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * MIB;
9486
9176
  var LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 2.5 * MIB;
9487
- var LAMBDA_RESERVED_COMPRESSED_SIZE = 250 * KIB;
9488
9177
 
9489
9178
  // src/edge-function-source/get-edge-function-source.ts
9490
9179
  var import_zlib = __toESM(require("zlib"));
@@ -9498,7 +9187,7 @@ var prettyBytes = (n) => (0, import_bytes.default)(n, { unitSeparator: " " });
9498
9187
  var import_get_nextjs_edge_function = __toESM(require_get_nextjs_edge_function());
9499
9188
  var gzip = (0, import_util.promisify)(import_zlib.default.gzip);
9500
9189
  async function getNextjsEdgeFunctionSource(filePaths, params, outputDir, wasm) {
9501
- const chunks = new import_webpack_sources2.ConcatSource(raw(`let _ENTRIES = {};`));
9190
+ const chunks = new import_webpack_sources2.ConcatSource(raw(`globalThis._ENTRIES = {};`));
9502
9191
  for (const filePath of filePaths) {
9503
9192
  const fullFilePath = (0, import_path.join)(outputDir, filePath);
9504
9193
  const content = await (0, import_fs_extra2.readFile)(fullFilePath, "utf8");
@@ -9893,7 +9582,7 @@ function getFilesMapFromReasons(fileList, reasons, ignoreFn) {
9893
9582
  }
9894
9583
  return parentFilesMap;
9895
9584
  }
9896
- var collectTracedFiles = (baseDir, lstatResults, lstatSema, reasons, files) => async (file) => {
9585
+ var collectTracedFiles = async (file, baseDir, lstatResults, lstatSema, reasons, files) => {
9897
9586
  const reason = reasons.get(file);
9898
9587
  if (reason && reason.type.includes("initial")) {
9899
9588
  return;
@@ -9909,47 +9598,42 @@ var collectTracedFiles = (baseDir, lstatResults, lstatSema, reasons, files) => a
9909
9598
  });
9910
9599
  };
9911
9600
  var ExperimentalTraceVersion = `9.0.4-canary.1`;
9912
- var compressBuffer = (buf) => {
9913
- return new Promise((resolve, reject) => {
9914
- import_zlib2.default.deflateRaw(
9915
- buf,
9916
- { level: import_zlib2.default.constants.Z_BEST_COMPRESSION },
9917
- (err, compBuf) => {
9918
- if (err)
9919
- return reject(err);
9920
- resolve(compBuf);
9921
- }
9922
- );
9923
- });
9924
- };
9925
- async function createPseudoLayer(files) {
9926
- const pseudoLayer = {};
9601
+ async function createPseudoLayer({
9602
+ files,
9603
+ lstatSema,
9604
+ lstatResults
9605
+ }) {
9927
9606
  let pseudoLayerBytes = 0;
9928
- for (const fileName of Object.keys(files)) {
9929
- const file = files[fileName];
9930
- if ((0, import_build_utils.isSymbolicLink)(file.mode)) {
9931
- const symlinkTarget = await import_fs_extra3.default.readlink(file.fsPath);
9932
- pseudoLayer[fileName] = {
9933
- file,
9934
- isSymlink: true,
9935
- symlinkTarget
9936
- };
9937
- } else {
9938
- const origBuffer = await (0, import_build_utils.streamToBuffer)(file.toStream());
9939
- const compBuffer = await compressBuffer(origBuffer);
9940
- pseudoLayerBytes += compBuffer.byteLength;
9941
- pseudoLayer[fileName] = {
9942
- file,
9943
- compBuffer,
9944
- isSymlink: false,
9945
- crc32: import_buffer_crc32.default.unsigned(origBuffer),
9946
- uncompressedSize: origBuffer.byteLength
9947
- };
9948
- }
9949
- }
9607
+ const pseudoLayer = {};
9608
+ const fileNames = Object.keys(files);
9609
+ await Promise.all(
9610
+ fileNames.map(async (fileName) => {
9611
+ await lstatSema.acquire();
9612
+ const file = files[fileName];
9613
+ if ((0, import_build_utils.isSymbolicLink)(file.mode)) {
9614
+ const symlinkTarget = await import_fs_extra3.default.readlink(file.fsPath);
9615
+ pseudoLayer[fileName] = {
9616
+ file,
9617
+ isSymlink: true,
9618
+ symlinkTarget
9619
+ };
9620
+ } else {
9621
+ if (!lstatResults[file.fsPath]) {
9622
+ lstatResults[file.fsPath] = lstatSema.acquire().then(() => (0, import_fs_extra3.lstat)(file.fsPath)).finally(() => lstatSema.release());
9623
+ }
9624
+ const { size } = await lstatResults[file.fsPath];
9625
+ pseudoLayerBytes += size;
9626
+ pseudoLayer[fileName] = {
9627
+ file,
9628
+ isSymlink: false,
9629
+ uncompressedSize: size
9630
+ };
9631
+ }
9632
+ lstatSema.release();
9633
+ })
9634
+ );
9950
9635
  return { pseudoLayer, pseudoLayerBytes };
9951
9636
  }
9952
- var createLambdaSema = new import_async_sema.Sema(1);
9953
9637
  async function createLambdaFromPseudoLayers({
9954
9638
  files: baseFiles,
9955
9639
  layers,
@@ -9957,7 +9641,6 @@ async function createLambdaFromPseudoLayers({
9957
9641
  nextVersion,
9958
9642
  ...lambdaOptions
9959
9643
  }) {
9960
- await createLambdaSema.acquire();
9961
9644
  const files = {};
9962
9645
  const addedFiles = /* @__PURE__ */ new Set();
9963
9646
  for (const layer of layers) {
@@ -9978,7 +9661,6 @@ async function createLambdaFromPseudoLayers({
9978
9661
  files[fileName] = file;
9979
9662
  addedFiles.add(fileName);
9980
9663
  }
9981
- createLambdaSema.release();
9982
9664
  return new import_build_utils.NodejsLambda({
9983
9665
  ...lambdaOptions,
9984
9666
  ...isStreaming ? {
@@ -10323,8 +10005,6 @@ async function getPageLambdaGroups({
10323
10005
  compressedPages,
10324
10006
  tracedPseudoLayer,
10325
10007
  initialPseudoLayer,
10326
- initialPseudoLayerUncompressed,
10327
- lambdaCompressedByteLimit,
10328
10008
  internalPages,
10329
10009
  pageExtensions
10330
10010
  }) {
@@ -10352,22 +10032,18 @@ async function getPageLambdaGroups({
10352
10032
  let matchingGroup = groups.find((group) => {
10353
10033
  const matches = group.maxDuration === opts.maxDuration && group.memory === opts.memory && group.isPrerenders === isPrerenderRoute;
10354
10034
  if (matches) {
10355
- let newTracedFilesSize = group.pseudoLayerBytes;
10356
- let newTracedFilesUncompressedSize = group.pseudoLayerUncompressedBytes;
10035
+ let newTracedFilesUncompressedSize = group.pseudoLayerBytes;
10357
10036
  for (const newPage of newPages) {
10358
10037
  Object.keys(pageTraces[newPage] || {}).map((file) => {
10359
10038
  if (!group.pseudoLayer[file]) {
10360
10039
  const item = tracedPseudoLayer[file];
10361
- newTracedFilesSize += item.compBuffer?.byteLength || 0;
10362
10040
  newTracedFilesUncompressedSize += item.uncompressedSize || 0;
10363
10041
  }
10364
10042
  });
10365
- newTracedFilesSize += compressedPages[newPage].compBuffer.byteLength;
10366
10043
  newTracedFilesUncompressedSize += compressedPages[newPage].uncompressedSize;
10367
10044
  }
10368
10045
  const underUncompressedLimit = newTracedFilesUncompressedSize < MAX_UNCOMPRESSED_LAMBDA_SIZE - LAMBDA_RESERVED_UNCOMPRESSED_SIZE;
10369
- const underCompressedLimit = newTracedFilesSize < lambdaCompressedByteLimit - LAMBDA_RESERVED_COMPRESSED_SIZE;
10370
- return underUncompressedLimit && underCompressedLimit;
10046
+ return underUncompressedLimit;
10371
10047
  }
10372
10048
  return false;
10373
10049
  });
@@ -10380,7 +10056,6 @@ async function getPageLambdaGroups({
10380
10056
  isPrerenders: isPrerenderRoute,
10381
10057
  isApiLambda: !!isApiPage(page),
10382
10058
  pseudoLayerBytes: initialPseudoLayer.pseudoLayerBytes,
10383
- pseudoLayerUncompressedBytes: initialPseudoLayerUncompressed,
10384
10059
  pseudoLayer: Object.assign({}, initialPseudoLayer.pseudoLayer)
10385
10060
  };
10386
10061
  groups.push(newGroup);
@@ -10389,31 +10064,24 @@ async function getPageLambdaGroups({
10389
10064
  for (const newPage of newPages) {
10390
10065
  Object.keys(pageTraces[newPage] || {}).map((file) => {
10391
10066
  const pseudoItem = tracedPseudoLayer[file];
10392
- const compressedSize = pseudoItem?.compBuffer?.byteLength || 0;
10393
10067
  if (!matchingGroup.pseudoLayer[file]) {
10394
10068
  matchingGroup.pseudoLayer[file] = pseudoItem;
10395
- matchingGroup.pseudoLayerBytes += compressedSize;
10396
- matchingGroup.pseudoLayerUncompressedBytes += pseudoItem.uncompressedSize || 0;
10069
+ matchingGroup.pseudoLayerBytes += pseudoItem.uncompressedSize || 0;
10397
10070
  }
10398
10071
  });
10399
- matchingGroup.pseudoLayerBytes += compressedPages[newPage].compBuffer.byteLength;
10400
- matchingGroup.pseudoLayerUncompressedBytes += compressedPages[newPage].uncompressedSize;
10072
+ matchingGroup.pseudoLayerBytes += compressedPages[newPage].uncompressedSize;
10401
10073
  }
10402
10074
  }
10403
10075
  return groups;
10404
10076
  }
10405
- var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLayerUncompressedBytes, compressedPages) => {
10077
+ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, compressedPages) => {
10406
10078
  const exceededLimitOutput = [];
10407
10079
  console.log(
10408
10080
  `Serverless Function's page${pages.length === 1 ? "" : "s"}: ${pages.join(
10409
10081
  ", "
10410
10082
  )}`
10411
10083
  );
10412
- exceededLimitOutput.push([
10413
- "Large Dependencies",
10414
- "Uncompressed size",
10415
- "Compressed size"
10416
- ]);
10084
+ exceededLimitOutput.push(["Large Dependencies", "Uncompressed size"]);
10417
10085
  const dependencies = {};
10418
10086
  for (const fileKey of Object.keys(pseudoLayer)) {
10419
10087
  if (!pseudoLayer[fileKey].isSymlink) {
@@ -10421,17 +10089,14 @@ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLa
10421
10089
  const depKey = fileKey.split("/").slice(0, 3).join("/");
10422
10090
  if (!dependencies[depKey]) {
10423
10091
  dependencies[depKey] = {
10424
- compressed: 0,
10425
10092
  uncompressed: 0
10426
10093
  };
10427
10094
  }
10428
- dependencies[depKey].compressed += fileItem.compBuffer.byteLength;
10429
10095
  dependencies[depKey].uncompressed += fileItem.uncompressedSize;
10430
10096
  }
10431
10097
  }
10432
10098
  for (const page of pages) {
10433
10099
  dependencies[`pages/${page}`] = {
10434
- compressed: compressedPages[page].compBuffer.byteLength,
10435
10100
  uncompressed: compressedPages[page].uncompressedSize
10436
10101
  };
10437
10102
  }
@@ -10439,23 +10104,19 @@ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLa
10439
10104
  Object.keys(dependencies).sort((a, b) => {
10440
10105
  const aDep = dependencies[a];
10441
10106
  const bDep = dependencies[b];
10442
- if (aDep.compressed > bDep.compressed) {
10107
+ if (aDep.uncompressed > bDep.uncompressed) {
10443
10108
  return -1;
10444
10109
  }
10445
- if (aDep.compressed < bDep.compressed) {
10110
+ if (aDep.uncompressed < bDep.uncompressed) {
10446
10111
  return 1;
10447
10112
  }
10448
10113
  return 0;
10449
10114
  }).forEach((depKey) => {
10450
10115
  const dep = dependencies[depKey];
10451
- if (dep.compressed < 100 * KIB && dep.uncompressed < 500 * KIB) {
10116
+ if (dep.uncompressed < 500 * KIB) {
10452
10117
  return;
10453
10118
  }
10454
- exceededLimitOutput.push([
10455
- depKey,
10456
- prettyBytes(dep.uncompressed),
10457
- prettyBytes(dep.compressed)
10458
- ]);
10119
+ exceededLimitOutput.push([depKey, prettyBytes(dep.uncompressed)]);
10459
10120
  numLargeDependencies += 1;
10460
10121
  });
10461
10122
  if (numLargeDependencies === 0) {
@@ -10464,26 +10125,21 @@ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerBytes, pseudoLa
10464
10125
  ]);
10465
10126
  }
10466
10127
  exceededLimitOutput.push([]);
10467
- exceededLimitOutput.push([
10468
- "All dependencies",
10469
- prettyBytes(pseudoLayerUncompressedBytes),
10470
- prettyBytes(pseudoLayerBytes)
10471
- ]);
10128
+ exceededLimitOutput.push(["All dependencies", prettyBytes(pseudoLayerBytes)]);
10472
10129
  console.log(
10473
10130
  (0, import_text_table.default)(exceededLimitOutput, {
10474
10131
  align: ["l", "r", "r"]
10475
10132
  })
10476
10133
  );
10477
10134
  };
10478
- var detectLambdaLimitExceeding = async (lambdaGroups, compressedSizeLimit, compressedPages) => {
10479
- const COMPRESSED_SIZE_LIMIT_CLOSE = compressedSizeLimit - 5 * MIB;
10135
+ var detectLambdaLimitExceeding = async (lambdaGroups, compressedPages) => {
10480
10136
  const UNCOMPRESSED_SIZE_LIMIT_CLOSE = MAX_UNCOMPRESSED_LAMBDA_SIZE - 5 * MIB;
10481
10137
  let numExceededLimit = 0;
10482
10138
  let numCloseToLimit = 0;
10483
10139
  let loggedHeadInfo = false;
10484
10140
  const filteredGroups = lambdaGroups.filter((group) => {
10485
- const exceededLimit = group.pseudoLayerBytes > compressedSizeLimit || group.pseudoLayerUncompressedBytes > MAX_UNCOMPRESSED_LAMBDA_SIZE;
10486
- const closeToLimit = group.pseudoLayerBytes > COMPRESSED_SIZE_LIMIT_CLOSE || group.pseudoLayerUncompressedBytes > UNCOMPRESSED_SIZE_LIMIT_CLOSE;
10141
+ const exceededLimit = group.pseudoLayerBytes > MAX_UNCOMPRESSED_LAMBDA_SIZE;
10142
+ const closeToLimit = group.pseudoLayerBytes > UNCOMPRESSED_SIZE_LIMIT_CLOSE;
10487
10143
  if (closeToLimit || exceededLimit || (0, import_build_utils.getPlatformEnv)("BUILDER_DEBUG") || process.env.NEXT_DEBUG_FUNCTION_SIZE) {
10488
10144
  if (exceededLimit) {
10489
10145
  numExceededLimit += 1;
@@ -10499,8 +10155,6 @@ var detectLambdaLimitExceeding = async (lambdaGroups, compressedSizeLimit, compr
10499
10155
  if (numExceededLimit || numCloseToLimit) {
10500
10156
  console.log(
10501
10157
  `Warning: Max serverless function size of ${prettyBytes(
10502
- compressedSizeLimit
10503
- )} compressed or ${prettyBytes(
10504
10158
  MAX_UNCOMPRESSED_LAMBDA_SIZE
10505
10159
  )} uncompressed${numExceededLimit ? "" : " almost"} reached`
10506
10160
  );
@@ -10513,7 +10167,6 @@ var detectLambdaLimitExceeding = async (lambdaGroups, compressedSizeLimit, compr
10513
10167
  group.pages,
10514
10168
  group.pseudoLayer,
10515
10169
  group.pseudoLayerBytes,
10516
- group.pseudoLayerUncompressedBytes,
10517
10170
  compressedPages
10518
10171
  );
10519
10172
  }
@@ -11001,9 +10654,12 @@ function normalizeEdgeFunctionPath(shortPath, appPathRoutesManifest) {
11001
10654
  if (shortPath.startsWith("app/") && (shortPath.endsWith("/page") || shortPath.endsWith("/route") || shortPath === "app/_not-found")) {
11002
10655
  const ogRoute = shortPath.replace(/^app\//, "/");
11003
10656
  shortPath = (appPathRoutesManifest[ogRoute] || shortPath.replace(/(^|\/)(page|route)$/, "")).replace(/^\//, "");
11004
- if (!shortPath || shortPath === "/") {
11005
- shortPath = "index";
11006
- }
10657
+ }
10658
+ if (shortPath.startsWith("pages/")) {
10659
+ shortPath = shortPath.replace(/^pages\//, "");
10660
+ }
10661
+ if (!shortPath || shortPath === "/") {
10662
+ shortPath = "index";
11007
10663
  }
11008
10664
  return shortPath;
11009
10665
  }
@@ -11746,7 +11402,7 @@ var legacy_versions_default = [
11746
11402
  // src/server-build.ts
11747
11403
  var import_path4 = __toESM(require("path"));
11748
11404
  var import_semver3 = __toESM(require_semver());
11749
- var import_async_sema2 = __toESM(require_lib());
11405
+ var import_async_sema = __toESM(require_lib());
11750
11406
  var import_build_utils2 = require("@vercel/build-utils");
11751
11407
  var import_nft = require("@vercel/nft");
11752
11408
  var import_resolve_from = __toESM(require_resolve_from());
@@ -11798,7 +11454,6 @@ async function serverBuild({
11798
11454
  omittedPrerenderRoutes,
11799
11455
  trailingSlashRedirects,
11800
11456
  isCorrectLocaleAPIRoutes,
11801
- lambdaCompressedByteLimit,
11802
11457
  requiredServerFilesManifest,
11803
11458
  variantsManifest
11804
11459
  }) {
@@ -11866,7 +11521,7 @@ async function serverBuild({
11866
11521
  if (!hasStatic500 && i18n) {
11867
11522
  hasStatic500 = !!staticPages[import_path4.default.posix.join(entryDirectory, i18n.defaultLocale, "500")];
11868
11523
  }
11869
- const lstatSema = new import_async_sema2.Sema(25);
11524
+ const lstatSema = new import_async_sema.Sema(25);
11870
11525
  const lstatResults = {};
11871
11526
  const nonLambdaSsgPages = /* @__PURE__ */ new Set();
11872
11527
  Object.keys(prerenderManifest.staticRoutes).forEach((route) => {
@@ -11991,18 +11646,23 @@ async function serverBuild({
11991
11646
  }
11992
11647
  (0, import_build_utils2.debug)("collecting initial Next.js server files");
11993
11648
  await Promise.all(
11994
- initialFileList.map(
11995
- collectTracedFiles(
11649
+ initialFileList.map(async (file) => {
11650
+ await collectTracedFiles(
11651
+ file,
11996
11652
  baseDir,
11997
11653
  lstatResults,
11998
11654
  lstatSema,
11999
11655
  initialFileReasons,
12000
11656
  initialTracedFiles
12001
- )
12002
- )
11657
+ );
11658
+ })
12003
11659
  );
12004
11660
  (0, import_build_utils2.debug)("creating initial pseudo layer");
12005
- const initialPseudoLayer = await createPseudoLayer(initialTracedFiles);
11661
+ const initialPseudoLayer = await createPseudoLayer({
11662
+ files: initialTracedFiles,
11663
+ lstatResults,
11664
+ lstatSema
11665
+ });
12006
11666
  console.timeEnd(initialTracingLabel);
12007
11667
  const lambdaCreationLabel = "Created all serverless functions in";
12008
11668
  console.time(lambdaCreationLabel);
@@ -12010,13 +11670,13 @@ async function serverBuild({
12010
11670
  const nonApiPages = [];
12011
11671
  const appRouterPages = [];
12012
11672
  const appRouteHandlers = [];
12013
- lambdaPageKeys.forEach((page) => {
11673
+ for (const page of lambdaPageKeys) {
12014
11674
  if (internalPages.includes(page) && page !== "404.js" && !(page === "_error.js" && !(static404Page || lambdaPages["404.js"]))) {
12015
- return;
11675
+ continue;
12016
11676
  }
12017
11677
  const pathname = page.replace(/\.js$/, "");
12018
11678
  if (nonLambdaSsgPages.has(pathname)) {
12019
- return;
11679
+ continue;
12020
11680
  }
12021
11681
  const normalizedPathname = normalizePage(pathname);
12022
11682
  if (isDynamicRoute(normalizedPathname)) {
@@ -12033,7 +11693,7 @@ async function serverBuild({
12033
11693
  } else {
12034
11694
  nonApiPages.push(page);
12035
11695
  }
12036
- });
11696
+ }
12037
11697
  const requiredFiles = {};
12038
11698
  requiredFiles[import_path4.default.relative(baseDir, nextServerFile)] = new import_build_utils2.FileFsRef({
12039
11699
  mode: (await import_fs_extra5.default.lstat(nextServerFile)).mode,
@@ -12099,33 +11759,28 @@ async function serverBuild({
12099
11759
  });
12100
11760
  })
12101
11761
  );
12102
- const requiredFilesLayer = await createPseudoLayer(requiredFiles);
11762
+ const requiredFilesLayer = await createPseudoLayer({
11763
+ files: requiredFiles,
11764
+ lstatResults,
11765
+ lstatSema
11766
+ });
12103
11767
  Object.assign(
12104
11768
  initialPseudoLayer.pseudoLayer,
12105
11769
  requiredFilesLayer.pseudoLayer
12106
11770
  );
12107
11771
  initialPseudoLayer.pseudoLayerBytes += requiredFilesLayer.pseudoLayerBytes;
12108
- const uncompressedInitialSize = Object.keys(
12109
- initialPseudoLayer.pseudoLayer
12110
- ).reduce((prev, cur) => {
12111
- const file = initialPseudoLayer.pseudoLayer[cur];
12112
- return prev + file.uncompressedSize || 0;
12113
- }, 0);
12114
11772
  (0, import_build_utils2.debug)(
12115
11773
  JSON.stringify(
12116
11774
  {
12117
- uncompressedInitialSize,
12118
- compressedInitialSize: initialPseudoLayer.pseudoLayerBytes
11775
+ initializeSizeUncompressed: initialPseudoLayer.pseudoLayerBytes
12119
11776
  },
12120
11777
  null,
12121
11778
  2
12122
11779
  )
12123
11780
  );
12124
- if (initialPseudoLayer.pseudoLayerBytes > lambdaCompressedByteLimit || uncompressedInitialSize > MAX_UNCOMPRESSED_LAMBDA_SIZE) {
11781
+ if (initialPseudoLayer.pseudoLayerBytes > MAX_UNCOMPRESSED_LAMBDA_SIZE) {
12125
11782
  console.log(
12126
11783
  `Warning: Max serverless function size of ${(0, import_pretty_bytes3.default)(
12127
- lambdaCompressedByteLimit
12128
- )} compressed or ${(0, import_pretty_bytes3.default)(
12129
11784
  MAX_UNCOMPRESSED_LAMBDA_SIZE
12130
11785
  )} uncompressed reached`
12131
11786
  );
@@ -12133,11 +11788,10 @@ async function serverBuild({
12133
11788
  [],
12134
11789
  initialPseudoLayer.pseudoLayer,
12135
11790
  initialPseudoLayer.pseudoLayerBytes,
12136
- uncompressedInitialSize,
12137
11791
  {}
12138
11792
  );
12139
11793
  throw new import_build_utils2.NowBuildError({
12140
- message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${lambdaCompressedByteLimit} bytes`,
11794
+ message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${MAX_UNCOMPRESSED_LAMBDA_SIZE} bytes`,
12141
11795
  code: "NEXT_REQUIRED_FILES_LIMIT",
12142
11796
  link: "https://vercel.com/docs/platform/limits#serverless-function-size"
12143
11797
  });
@@ -12161,12 +11815,12 @@ async function serverBuild({
12161
11815
  useBundledServer ? BUNDLED_SERVER_NEXT_PATH : `${getNextServerPath(nextVersion)}/next-server.js`
12162
11816
  );
12163
11817
  const appLauncher = launcher.replace(
12164
- "// pre-next-server-target",
11818
+ "// @preserve pre-next-server-target",
12165
11819
  `process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = "${requiredServerFilesManifest.config?.experimental?.serverActions ? "experimental" : "next"}"`
12166
11820
  );
12167
11821
  if (entryDirectory !== "." && import_path4.default.posix.join("/", entryDirectory) !== routesManifest.basePath) {
12168
11822
  launcher = launcher.replace(
12169
- "// entryDirectory handler",
11823
+ "// @preserve entryDirectory handler",
12170
11824
  `req.url = req.url.replace(/^${import_path4.default.posix.join("/", entryDirectory).replace(/\//g, "\\/")}/, '')`
12171
11825
  );
12172
11826
  }
@@ -12188,17 +11842,22 @@ async function serverBuild({
12188
11842
  }
12189
11843
  return originalPagePath;
12190
11844
  };
12191
- const getBuildTraceFile = (page) => {
12192
- return pageBuildTraces[page + ".nft.json"] || appBuildTraces[page + ".nft.json"];
12193
- };
11845
+ const getBuildTraceFile = (page) => pageBuildTraces[page + ".nft.json"] || appBuildTraces[page + ".nft.json"];
12194
11846
  const pathsToTrace = mergedPageKeys.map((page) => {
12195
- if (!getBuildTraceFile(page)) {
11847
+ const originalPagePath = getOriginalPagePath(page);
11848
+ const pageBuildTrace = getBuildTraceFile(originalPagePath);
11849
+ if (!pageBuildTrace) {
12196
11850
  return lambdaPages[page].fsPath;
12197
11851
  }
12198
11852
  }).filter(Boolean);
12199
11853
  let traceResult;
12200
11854
  let parentFilesMap;
12201
11855
  if (pathsToTrace.length > 0) {
11856
+ console.warn(
11857
+ `Warning: running tracing as trace files were not present for:
11858
+ `,
11859
+ JSON.stringify(pathsToTrace, null, 2)
11860
+ );
12202
11861
  traceResult = await (0, import_nft.nodeFileTrace)(pathsToTrace, {
12203
11862
  base: baseDir,
12204
11863
  cache: traceCache,
@@ -12264,28 +11923,37 @@ async function serverBuild({
12264
11923
  }
12265
11924
  reasons = traceResult?.reasons || /* @__PURE__ */ new Map();
12266
11925
  }
12267
- await Promise.all(
12268
- fileList.map(
12269
- collectTracedFiles(
11926
+ await Promise.all([
11927
+ createPseudoLayer({
11928
+ files: {
11929
+ [page]: lambdaPages[page]
11930
+ },
11931
+ lstatResults,
11932
+ lstatSema
11933
+ }).then((res) => {
11934
+ compressedPages[page] = res.pseudoLayer[page];
11935
+ }),
11936
+ ...fileList.map(async (file) => {
11937
+ await collectTracedFiles(
11938
+ file,
12270
11939
  baseDir,
12271
11940
  lstatResults,
12272
11941
  lstatSema,
12273
11942
  reasons,
12274
11943
  tracedFiles
12275
- )
12276
- )
12277
- );
11944
+ );
11945
+ })
11946
+ ]);
12278
11947
  pageTraces[page] = tracedFiles;
12279
- compressedPages[page] = (await createPseudoLayer({
12280
- [page]: lambdaPages[page]
12281
- })).pseudoLayer[page];
12282
11948
  }
12283
- const tracedPseudoLayer = await createPseudoLayer(
12284
- mergedPageKeys.reduce((prev, page) => {
11949
+ const tracedPseudoLayer = await createPseudoLayer({
11950
+ files: mergedPageKeys.reduce((prev, page) => {
12285
11951
  Object.assign(prev, pageTraces[page]);
12286
11952
  return prev;
12287
- }, {})
12288
- );
11953
+ }, {}),
11954
+ lstatResults,
11955
+ lstatSema
11956
+ });
12289
11957
  const pageExtensions = requiredServerFilesManifest.config?.pageExtensions;
12290
11958
  const pageLambdaGroups = await getPageLambdaGroups({
12291
11959
  entryPath: projectDir,
@@ -12297,8 +11965,6 @@ async function serverBuild({
12297
11965
  compressedPages,
12298
11966
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12299
11967
  initialPseudoLayer,
12300
- lambdaCompressedByteLimit,
12301
- initialPseudoLayerUncompressed: uncompressedInitialSize,
12302
11968
  internalPages,
12303
11969
  pageExtensions
12304
11970
  });
@@ -12315,8 +11981,6 @@ async function serverBuild({
12315
11981
  compressedPages,
12316
11982
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12317
11983
  initialPseudoLayer,
12318
- lambdaCompressedByteLimit,
12319
- initialPseudoLayerUncompressed: uncompressedInitialSize,
12320
11984
  internalPages,
12321
11985
  pageExtensions
12322
11986
  });
@@ -12330,8 +11994,6 @@ async function serverBuild({
12330
11994
  compressedPages,
12331
11995
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12332
11996
  initialPseudoLayer,
12333
- lambdaCompressedByteLimit,
12334
- initialPseudoLayerUncompressed: uncompressedInitialSize,
12335
11997
  internalPages,
12336
11998
  pageExtensions
12337
11999
  });
@@ -12358,8 +12020,6 @@ async function serverBuild({
12358
12020
  compressedPages,
12359
12021
  tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
12360
12022
  initialPseudoLayer,
12361
- initialPseudoLayerUncompressed: uncompressedInitialSize,
12362
- lambdaCompressedByteLimit,
12363
12023
  internalPages,
12364
12024
  pageExtensions
12365
12025
  });
@@ -12372,27 +12032,23 @@ async function serverBuild({
12372
12032
  apiLambdaGroups: apiLambdaGroups.map((group) => ({
12373
12033
  pages: group.pages,
12374
12034
  isPrerender: group.isPrerenders,
12375
- pseudoLayerBytes: group.pseudoLayerBytes,
12376
- uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
12035
+ pseudoLayerBytes: group.pseudoLayerBytes
12377
12036
  })),
12378
12037
  pageLambdaGroups: pageLambdaGroups.map((group) => ({
12379
12038
  pages: group.pages,
12380
12039
  isPrerender: group.isPrerenders,
12381
- pseudoLayerBytes: group.pseudoLayerBytes,
12382
- uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
12040
+ pseudoLayerBytes: group.pseudoLayerBytes
12383
12041
  })),
12384
12042
  appRouterLambdaGroups: appRouterLambdaGroups.map((group) => ({
12385
12043
  pages: group.pages,
12386
12044
  isPrerender: group.isPrerenders,
12387
- pseudoLayerBytes: group.pseudoLayerBytes,
12388
- uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
12045
+ pseudoLayerBytes: group.pseudoLayerBytes
12389
12046
  })),
12390
12047
  appRouteHandlersLambdaGroups: appRouteHandlersLambdaGroups.map(
12391
12048
  (group) => ({
12392
12049
  pages: group.pages,
12393
12050
  isPrerender: group.isPrerenders,
12394
- pseudoLayerBytes: group.pseudoLayerBytes,
12395
- uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
12051
+ pseudoLayerBytes: group.pseudoLayerBytes
12396
12052
  })
12397
12053
  ),
12398
12054
  nextServerLayerSize: initialPseudoLayer.pseudoLayerBytes
@@ -12407,118 +12063,121 @@ async function serverBuild({
12407
12063
  ...apiLambdaGroups,
12408
12064
  ...appRouteHandlersLambdaGroups
12409
12065
  ];
12410
- await detectLambdaLimitExceeding(
12411
- combinedGroups,
12412
- lambdaCompressedByteLimit,
12413
- compressedPages
12414
- );
12415
- for (const group of combinedGroups) {
12416
- const groupPageFiles = {};
12417
- for (const page of [...group.pages, ...internalPages]) {
12418
- const pageFileName = import_path4.default.normalize(
12419
- import_path4.default.relative(baseDir, lambdaPages[page].fsPath)
12420
- );
12421
- groupPageFiles[pageFileName] = compressedPages[page];
12422
- }
12423
- const updatedManifestFiles = {};
12424
- if (isCorrectManifests) {
12425
- for (const manifest of [
12426
- "routes-manifest.json",
12427
- "server/pages-manifest.json"
12428
- ]) {
12429
- const fsPath = import_path4.default.join(entryPath, outputDirectory, manifest);
12430
- const relativePath = import_path4.default.relative(baseDir, fsPath);
12431
- delete group.pseudoLayer[relativePath];
12432
- const manifestData = await import_fs_extra5.default.readJSON(fsPath);
12433
- const normalizedPages = new Set(
12434
- group.pages.map((page) => {
12435
- page = `/${page.replace(/\.js$/, "")}`;
12436
- if (page === "/index")
12437
- page = "/";
12438
- return page;
12439
- })
12066
+ await detectLambdaLimitExceeding(combinedGroups, compressedPages);
12067
+ await Promise.all(
12068
+ combinedGroups.map(async (group) => {
12069
+ const groupPageFiles = {};
12070
+ for (const page of [...group.pages, ...internalPages]) {
12071
+ const pageFileName = import_path4.default.normalize(
12072
+ import_path4.default.relative(baseDir, lambdaPages[page].fsPath)
12440
12073
  );
12441
- switch (manifest) {
12442
- case "routes-manifest.json": {
12443
- const filterItem = (item) => normalizedPages.has(item.page);
12444
- manifestData.dynamicRoutes = manifestData.dynamicRoutes?.filter(filterItem);
12445
- manifestData.staticRoutes = manifestData.staticRoutes?.filter(filterItem);
12446
- break;
12447
- }
12448
- case "server/pages-manifest.json": {
12449
- for (const key of Object.keys(manifestData)) {
12450
- if (isDynamicRoute(key) && !normalizedPages.has(key)) {
12451
- delete manifestData[key];
12074
+ groupPageFiles[pageFileName] = compressedPages[page];
12075
+ }
12076
+ const updatedManifestFiles = {};
12077
+ if (isCorrectManifests) {
12078
+ for (const manifest of [
12079
+ "routes-manifest.json",
12080
+ "server/pages-manifest.json"
12081
+ ]) {
12082
+ const fsPath = import_path4.default.join(entryPath, outputDirectory, manifest);
12083
+ const relativePath = import_path4.default.relative(baseDir, fsPath);
12084
+ delete group.pseudoLayer[relativePath];
12085
+ const manifestData = await import_fs_extra5.default.readJSON(fsPath);
12086
+ const normalizedPages = new Set(
12087
+ group.pages.map((page) => {
12088
+ page = `/${page.replace(/\.js$/, "")}`;
12089
+ if (page === "/index")
12090
+ page = "/";
12091
+ return page;
12092
+ })
12093
+ );
12094
+ switch (manifest) {
12095
+ case "routes-manifest.json": {
12096
+ const filterItem = (item) => normalizedPages.has(item.page);
12097
+ manifestData.dynamicRoutes = manifestData.dynamicRoutes?.filter(filterItem);
12098
+ manifestData.staticRoutes = manifestData.staticRoutes?.filter(filterItem);
12099
+ break;
12100
+ }
12101
+ case "server/pages-manifest.json": {
12102
+ for (const key of Object.keys(manifestData)) {
12103
+ if (isDynamicRoute(key) && !normalizedPages.has(key)) {
12104
+ delete manifestData[key];
12105
+ }
12452
12106
  }
12107
+ break;
12108
+ }
12109
+ default: {
12110
+ throw new import_build_utils2.NowBuildError({
12111
+ message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
12112
+ code: "NEXT_MANIFEST_INVARIANT"
12113
+ });
12453
12114
  }
12454
- break;
12455
- }
12456
- default: {
12457
- throw new import_build_utils2.NowBuildError({
12458
- message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
12459
- code: "NEXT_MANIFEST_INVARIANT"
12460
- });
12461
12115
  }
12116
+ updatedManifestFiles[relativePath] = new import_build_utils2.FileBlob({
12117
+ contentType: "application/json",
12118
+ data: JSON.stringify(manifestData)
12119
+ });
12462
12120
  }
12463
- updatedManifestFiles[relativePath] = new import_build_utils2.FileBlob({
12464
- contentType: "application/json",
12465
- data: JSON.stringify(manifestData)
12466
- });
12467
- }
12468
- }
12469
- const launcherFiles = {
12470
- [import_path4.default.join(import_path4.default.relative(baseDir, projectDir), "___next_launcher.cjs")]: new import_build_utils2.FileBlob({ data: group.isAppRouter ? appLauncher : launcher })
12471
- };
12472
- const operationType = getOperationType({ group, prerenderManifest });
12473
- const lambda = await createLambdaFromPseudoLayers({
12474
- files: {
12475
- ...launcherFiles,
12476
- ...updatedManifestFiles
12477
- },
12478
- layers: [group.pseudoLayer, groupPageFiles],
12479
- handler: import_path4.default.join(
12480
- import_path4.default.relative(baseDir, projectDir),
12481
- "___next_launcher.cjs"
12482
- ),
12483
- operationType,
12484
- memory: group.memory,
12485
- runtime: nodeVersion.runtime,
12486
- maxDuration: group.maxDuration,
12487
- isStreaming: group.isStreaming,
12488
- nextVersion
12489
- });
12490
- for (const page of group.pages) {
12491
- const pageNoExt = page.replace(/\.js$/, "");
12492
- let isPrerender = prerenderRoutes.has(
12493
- import_path4.default.join("/", pageNoExt === "index" ? "" : pageNoExt)
12494
- );
12495
- if (!isPrerender && routesManifest?.i18n) {
12496
- isPrerender = routesManifest.i18n.locales.some((locale) => {
12497
- return prerenderRoutes.has(
12498
- import_path4.default.join("/", locale, pageNoExt === "index" ? "" : pageNoExt)
12499
- );
12500
- });
12501
12121
  }
12502
- const outputName = normalizeIndexOutput(
12503
- import_path4.default.posix.join(entryDirectory, pageNoExt),
12504
- true
12505
- );
12506
- if (i18n && !isPrerender && !group.isAppRouter && (!isCorrectLocaleAPIRoutes || !(pageNoExt === "api" || pageNoExt.startsWith("api/")))) {
12507
- for (const locale of i18n.locales) {
12508
- lambdas[normalizeIndexOutput(
12509
- import_path4.default.posix.join(
12510
- entryDirectory,
12511
- locale,
12512
- pageNoExt === "index" ? "" : pageNoExt
12513
- ),
12514
- true
12515
- )] = lambda;
12122
+ const launcherFiles = {
12123
+ [import_path4.default.join(
12124
+ import_path4.default.relative(baseDir, projectDir),
12125
+ "___next_launcher.cjs"
12126
+ )]: new import_build_utils2.FileBlob({
12127
+ data: group.isAppRouter ? appLauncher : launcher
12128
+ })
12129
+ };
12130
+ const operationType = getOperationType({ group, prerenderManifest });
12131
+ const lambda = await createLambdaFromPseudoLayers({
12132
+ files: {
12133
+ ...launcherFiles,
12134
+ ...updatedManifestFiles
12135
+ },
12136
+ layers: [group.pseudoLayer, groupPageFiles],
12137
+ handler: import_path4.default.join(
12138
+ import_path4.default.relative(baseDir, projectDir),
12139
+ "___next_launcher.cjs"
12140
+ ),
12141
+ operationType,
12142
+ memory: group.memory,
12143
+ runtime: nodeVersion.runtime,
12144
+ maxDuration: group.maxDuration,
12145
+ isStreaming: group.isStreaming,
12146
+ nextVersion
12147
+ });
12148
+ for (const page of group.pages) {
12149
+ const pageNoExt = page.replace(/\.js$/, "");
12150
+ let isPrerender = prerenderRoutes.has(
12151
+ import_path4.default.join("/", pageNoExt === "index" ? "" : pageNoExt)
12152
+ );
12153
+ if (!isPrerender && routesManifest?.i18n) {
12154
+ isPrerender = routesManifest.i18n.locales.some((locale) => {
12155
+ return prerenderRoutes.has(
12156
+ import_path4.default.join("/", locale, pageNoExt === "index" ? "" : pageNoExt)
12157
+ );
12158
+ });
12159
+ }
12160
+ const outputName = normalizeIndexOutput(
12161
+ import_path4.default.posix.join(entryDirectory, pageNoExt),
12162
+ true
12163
+ );
12164
+ if (i18n && !isPrerender && !group.isAppRouter && (!isCorrectLocaleAPIRoutes || !(pageNoExt === "api" || pageNoExt.startsWith("api/")))) {
12165
+ for (const locale of i18n.locales) {
12166
+ lambdas[normalizeIndexOutput(
12167
+ import_path4.default.posix.join(
12168
+ entryDirectory,
12169
+ locale,
12170
+ pageNoExt === "index" ? "" : pageNoExt
12171
+ ),
12172
+ true
12173
+ )] = lambda;
12174
+ }
12175
+ } else {
12176
+ lambdas[outputName] = lambda;
12516
12177
  }
12517
- } else {
12518
- lambdas[outputName] = lambda;
12519
12178
  }
12520
- }
12521
- }
12179
+ })
12180
+ );
12522
12181
  console.timeEnd(lambdaCreationLabel);
12523
12182
  }
12524
12183
  const prerenderRoute = onPrerenderRoute({
@@ -14296,6 +13955,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14296
13955
  let tracedPseudoLayer;
14297
13956
  const apiPages = [];
14298
13957
  const nonApiPages = [];
13958
+ const lstatSema = new import_async_sema2.Sema(25);
13959
+ const lstatResults = {};
14299
13960
  for (const page of pageKeys) {
14300
13961
  const pagePath = pages[page].fsPath;
14301
13962
  const route = `/${page.replace(/\.js$/, "")}`;
@@ -14307,7 +13968,11 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14307
13968
  nonApiPages.push(page);
14308
13969
  }
14309
13970
  compressedPages[page] = (await createPseudoLayer({
14310
- [page]: pages[page]
13971
+ files: {
13972
+ [page]: pages[page]
13973
+ },
13974
+ lstatResults,
13975
+ lstatSema
14311
13976
  })).pseudoLayer[page];
14312
13977
  }
14313
13978
  const mergedPageKeys = [...nonApiPages, ...apiPages];
@@ -14318,8 +13983,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14318
13983
  console.time(tracingLabel);
14319
13984
  }
14320
13985
  const nftCache = /* @__PURE__ */ Object.create(null);
14321
- const lstatSema = new import_async_sema3.Sema(25);
14322
- const lstatResults = {};
14323
13986
  const pathsToTrace = mergedPageKeys.map((page) => pages[page].fsPath);
14324
13987
  const result = await (0, import_nft2.nodeFileTrace)(pathsToTrace, {
14325
13988
  base: baseDir,
@@ -14343,15 +14006,16 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14343
14006
  }
14344
14007
  const reasons = result.reasons;
14345
14008
  await Promise.all(
14346
- Array.from(fileList).map(
14347
- collectTracedFiles(
14009
+ Array.from(fileList).map(async (file) => {
14010
+ await collectTracedFiles(
14011
+ file,
14348
14012
  baseDir,
14349
14013
  lstatResults,
14350
14014
  lstatSema,
14351
14015
  reasons,
14352
14016
  tracedFiles
14353
- )
14354
- )
14017
+ );
14018
+ })
14355
14019
  );
14356
14020
  pageTraces[page] = tracedFiles;
14357
14021
  }
@@ -14362,12 +14026,14 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
14362
14026
  if (hasLambdas) {
14363
14027
  console.time(zippingLabel);
14364
14028
  }
14365
- tracedPseudoLayer = await createPseudoLayer(
14366
- mergedPageKeys.reduce((prev, page) => {
14029
+ tracedPseudoLayer = await createPseudoLayer({
14030
+ files: mergedPageKeys.reduce((prev, page) => {
14367
14031
  Object.assign(prev, pageTraces[page]);
14368
14032
  return prev;
14369
- }, {})
14370
- );
14033
+ }, {}),
14034
+ lstatResults,
14035
+ lstatSema
14036
+ });
14371
14037
  if (hasLambdas) {
14372
14038
  console.timeEnd(zippingLabel);
14373
14039
  }
@@ -10,6 +10,7 @@ if (process.env.NODE_ENV !== "production" && region !== "dev1") {
10
10
  );
11
11
  process.env.NODE_ENV = "production";
12
12
  }
13
+ // @preserve pre-next-server-target
13
14
  const NextServer = require("__NEXT_SERVER_PATH__").default;
14
15
  const nextServer = new NextServer({
15
16
  // @ts-ignore __NEXT_CONFIG__ value is injected
@@ -21,6 +22,7 @@ const nextServer = new NextServer({
21
22
  const requestHandler = nextServer.getRequestHandler();
22
23
  module.exports = async (req, res) => {
23
24
  try {
25
+ // @preserve entryDirectory handler
24
26
  await requestHandler(req, res);
25
27
  } catch (err) {
26
28
  console.error(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -13,7 +13,7 @@
13
13
  "dist"
14
14
  ],
15
15
  "dependencies": {
16
- "@vercel/nft": "0.24.1"
16
+ "@vercel/nft": "0.24.2"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/aws-lambda": "8.10.19",
@@ -30,7 +30,7 @@
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": "7.2.1",
33
+ "@vercel/build-utils": "7.2.2",
34
34
  "@vercel/routing-utils": "3.0.0",
35
35
  "async-sema": "3.0.1",
36
36
  "buffer-crc32": "0.2.13",