@vercel/next 4.1.6 → 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.
- package/dist/index.js +175 -83
- package/package.json +2 -2
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
|
9489
|
-
var LAMBDA_RESERVED_UNCOMPRESSED_SIZE =
|
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
|
-
|
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
|
-
|
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,
|
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.
|
10480
|
+
if (aDep.uncompressed > bDep.uncompressed) {
|
10502
10481
|
return -1;
|
10503
10482
|
}
|
10504
|
-
if (aDep.
|
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.
|
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 (>
|
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"
|
10507
|
+
align: ["l", "r"]
|
10534
10508
|
})
|
10535
10509
|
);
|
10536
10510
|
};
|
10537
|
-
var detectLambdaLimitExceeding = async (lambdaGroups,
|
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.
|
10545
|
-
const closeToLimit = group.
|
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
|
);
|
@@ -11307,7 +11277,8 @@ async function getMiddlewareBundle({
|
|
11307
11277
|
framework: {
|
11308
11278
|
slug: "nextjs",
|
11309
11279
|
version: nextVersion
|
11310
|
-
}
|
11280
|
+
},
|
11281
|
+
environment: edgeFunction.environments
|
11311
11282
|
});
|
11312
11283
|
})(),
|
11313
11284
|
routeMatchers: getRouteMatchers(edgeFunction, routesManifest)
|
@@ -11408,14 +11379,21 @@ async function getMiddlewareManifest(entryPath, outputDirectory) {
|
|
11408
11379
|
const manifest = await import_fs_extra3.default.readJSON(
|
11409
11380
|
middlewareManifestPath
|
11410
11381
|
);
|
11411
|
-
|
11382
|
+
if (manifest.version === 1) {
|
11383
|
+
return upgradeMiddlewareManifestV1(manifest);
|
11384
|
+
}
|
11385
|
+
if (manifest.version === 2) {
|
11386
|
+
return upgradeMiddlewareManifestV2(manifest);
|
11387
|
+
}
|
11388
|
+
return manifest;
|
11412
11389
|
}
|
11413
|
-
function
|
11390
|
+
function upgradeMiddlewareManifestV1(v1) {
|
11414
11391
|
function updateInfo(v1Info) {
|
11415
11392
|
const { regexp, ...rest } = v1Info;
|
11416
11393
|
return {
|
11417
11394
|
...rest,
|
11418
|
-
matchers: [{ regexp }]
|
11395
|
+
matchers: [{ regexp }],
|
11396
|
+
environments: {}
|
11419
11397
|
};
|
11420
11398
|
}
|
11421
11399
|
const middleware = Object.fromEntries(
|
@@ -11426,7 +11404,28 @@ function upgradeMiddlewareManifest(v1) {
|
|
11426
11404
|
) : void 0;
|
11427
11405
|
return {
|
11428
11406
|
...v1,
|
11429
|
-
version:
|
11407
|
+
version: 3,
|
11408
|
+
middleware,
|
11409
|
+
functions
|
11410
|
+
};
|
11411
|
+
}
|
11412
|
+
function upgradeMiddlewareManifestV2(v2) {
|
11413
|
+
function updateInfo(v2Info) {
|
11414
|
+
const { ...rest } = v2Info;
|
11415
|
+
return {
|
11416
|
+
...rest,
|
11417
|
+
environments: {}
|
11418
|
+
};
|
11419
|
+
}
|
11420
|
+
const middleware = Object.fromEntries(
|
11421
|
+
Object.entries(v2.middleware).map(([p, info]) => [p, updateInfo(info)])
|
11422
|
+
);
|
11423
|
+
const functions = v2.functions ? Object.fromEntries(
|
11424
|
+
Object.entries(v2.functions).map(([p, info]) => [p, updateInfo(info)])
|
11425
|
+
) : void 0;
|
11426
|
+
return {
|
11427
|
+
...v2,
|
11428
|
+
version: 3,
|
11430
11429
|
middleware,
|
11431
11430
|
functions
|
11432
11431
|
};
|
@@ -11990,6 +11989,7 @@ var CORRECT_NOT_FOUND_ROUTES_VERSION = "v12.0.1";
|
|
11990
11989
|
var CORRECT_MIDDLEWARE_ORDER_VERSION = "v12.1.7-canary.29";
|
11991
11990
|
var NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = "v12.1.7-canary.33";
|
11992
11991
|
var EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = "v12.2.0";
|
11992
|
+
var ACTION_OUTPUT_SUPPORT_VERSION = "v14.2.2";
|
11993
11993
|
var CORRECTED_MANIFESTS_VERSION = "v12.2.0";
|
11994
11994
|
var PRELOAD_CHUNKS = {
|
11995
11995
|
APP_ROUTER_PAGES: [
|
@@ -12052,7 +12052,6 @@ async function serverBuild({
|
|
12052
12052
|
omittedPrerenderRoutes,
|
12053
12053
|
trailingSlashRedirects,
|
12054
12054
|
isCorrectLocaleAPIRoutes,
|
12055
|
-
lambdaCompressedByteLimit,
|
12056
12055
|
requiredServerFilesManifest,
|
12057
12056
|
variantsManifest,
|
12058
12057
|
experimentalPPRRoutes
|
@@ -12070,6 +12069,10 @@ async function serverBuild({
|
|
12070
12069
|
nextVersion,
|
12071
12070
|
EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION
|
12072
12071
|
);
|
12072
|
+
const hasActionOutputSupport = import_semver3.default.gte(
|
12073
|
+
nextVersion,
|
12074
|
+
ACTION_OUTPUT_SUPPORT_VERSION
|
12075
|
+
);
|
12073
12076
|
const projectDir = requiredServerFilesManifest.relativeAppDir ? import_path4.default.join(baseDir, requiredServerFilesManifest.relativeAppDir) : requiredServerFilesManifest.appDir || entryPath;
|
12074
12077
|
const inversedAppPathManifest = {};
|
12075
12078
|
if (appPathRoutesManifest) {
|
@@ -12394,23 +12397,20 @@ async function serverBuild({
|
|
12394
12397
|
2
|
12395
12398
|
)
|
12396
12399
|
);
|
12397
|
-
if (
|
12400
|
+
if (uncompressedInitialSize > MAX_UNCOMPRESSED_LAMBDA_SIZE) {
|
12398
12401
|
console.log(
|
12399
12402
|
`Warning: Max serverless function size of ${(0, import_pretty_bytes3.default)(
|
12400
|
-
lambdaCompressedByteLimit
|
12401
|
-
)} compressed or ${(0, import_pretty_bytes3.default)(
|
12402
12403
|
MAX_UNCOMPRESSED_LAMBDA_SIZE
|
12403
12404
|
)} uncompressed reached`
|
12404
12405
|
);
|
12405
12406
|
outputFunctionFileSizeInfo(
|
12406
12407
|
[],
|
12407
12408
|
initialPseudoLayer.pseudoLayer,
|
12408
|
-
initialPseudoLayer.pseudoLayerBytes,
|
12409
12409
|
uncompressedInitialSize,
|
12410
12410
|
{}
|
12411
12411
|
);
|
12412
12412
|
throw new import_build_utils2.NowBuildError({
|
12413
|
-
message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${
|
12413
|
+
message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${MAX_UNCOMPRESSED_LAMBDA_SIZE} bytes`,
|
12414
12414
|
code: "NEXT_REQUIRED_FILES_LIMIT",
|
12415
12415
|
link: "https://vercel.com/docs/platform/limits#serverless-function-size"
|
12416
12416
|
});
|
@@ -12572,7 +12572,6 @@ async function serverBuild({
|
|
12572
12572
|
experimentalPPRRoutes: void 0,
|
12573
12573
|
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
12574
12574
|
initialPseudoLayer,
|
12575
|
-
lambdaCompressedByteLimit,
|
12576
12575
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
12577
12576
|
internalPages,
|
12578
12577
|
pageExtensions
|
@@ -12592,7 +12591,6 @@ async function serverBuild({
|
|
12592
12591
|
experimentalPPRRoutes,
|
12593
12592
|
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
12594
12593
|
initialPseudoLayer,
|
12595
|
-
lambdaCompressedByteLimit,
|
12596
12594
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
12597
12595
|
internalPages,
|
12598
12596
|
pageExtensions,
|
@@ -12610,17 +12608,24 @@ async function serverBuild({
|
|
12610
12608
|
experimentalPPRRoutes: void 0,
|
12611
12609
|
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
12612
12610
|
initialPseudoLayer,
|
12613
|
-
lambdaCompressedByteLimit,
|
12614
12611
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
12615
12612
|
internalPages,
|
12616
12613
|
pageExtensions,
|
12617
12614
|
inversedAppPathManifest
|
12618
12615
|
});
|
12616
|
+
const appRouterStreamingPrerenderLambdaGroups = [];
|
12619
12617
|
for (const group of appRouterLambdaGroups) {
|
12620
12618
|
if (!group.isPrerenders || group.isExperimentalPPR) {
|
12621
12619
|
group.isStreaming = true;
|
12622
12620
|
}
|
12623
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
|
+
}
|
12624
12629
|
}
|
12625
12630
|
for (const group of appRouteHandlersLambdaGroups) {
|
12626
12631
|
if (!group.isPrerenders) {
|
@@ -12641,7 +12646,6 @@ async function serverBuild({
|
|
12641
12646
|
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
12642
12647
|
initialPseudoLayer,
|
12643
12648
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
12644
|
-
lambdaCompressedByteLimit,
|
12645
12649
|
internalPages,
|
12646
12650
|
pageExtensions
|
12647
12651
|
});
|
@@ -12669,6 +12673,12 @@ async function serverBuild({
|
|
12669
12673
|
pseudoLayerBytes: group.pseudoLayerBytes,
|
12670
12674
|
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
12671
12675
|
})),
|
12676
|
+
appRouterStreamingPrerenderLambdaGroups: appRouterStreamingPrerenderLambdaGroups.map((group) => ({
|
12677
|
+
pages: group.pages,
|
12678
|
+
isPrerender: group.isPrerenders,
|
12679
|
+
pseudoLayerBytes: group.pseudoLayerBytes,
|
12680
|
+
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
12681
|
+
})),
|
12672
12682
|
appRouteHandlersLambdaGroups: appRouteHandlersLambdaGroups.map(
|
12673
12683
|
(group) => ({
|
12674
12684
|
pages: group.pages,
|
@@ -12686,17 +12696,20 @@ async function serverBuild({
|
|
12686
12696
|
const combinedGroups = [
|
12687
12697
|
...pageLambdaGroups,
|
12688
12698
|
...appRouterLambdaGroups,
|
12699
|
+
...appRouterStreamingPrerenderLambdaGroups,
|
12689
12700
|
...apiLambdaGroups,
|
12690
12701
|
...appRouteHandlersLambdaGroups
|
12691
12702
|
];
|
12692
|
-
await detectLambdaLimitExceeding(
|
12693
|
-
|
12694
|
-
|
12695
|
-
compressedPages
|
12696
|
-
);
|
12703
|
+
await detectLambdaLimitExceeding(combinedGroups, compressedPages);
|
12704
|
+
const appNotFoundTraces = pageTraces["_not-found.js"];
|
12705
|
+
const appNotFoundPsuedoLayer = appNotFoundTraces && await createPseudoLayer(appNotFoundTraces);
|
12697
12706
|
for (const group of combinedGroups) {
|
12698
12707
|
const groupPageFiles = {};
|
12699
|
-
for (const page of [
|
12708
|
+
for (const page of [
|
12709
|
+
...group.pages,
|
12710
|
+
...internalPages,
|
12711
|
+
...group.isAppRouter && appNotFoundTraces ? ["_not-found.js"] : []
|
12712
|
+
]) {
|
12700
12713
|
const pageFileName = import_path4.default.normalize(
|
12701
12714
|
import_path4.default.relative(baseDir, lambdaPages[page].fsPath)
|
12702
12715
|
);
|
@@ -12802,6 +12815,9 @@ async function serverBuild({
|
|
12802
12815
|
nextVersion,
|
12803
12816
|
experimentalAllowBundling
|
12804
12817
|
};
|
12818
|
+
if (group.isAppRouter && appNotFoundPsuedoLayer) {
|
12819
|
+
options.layers.push(appNotFoundPsuedoLayer.pseudoLayer);
|
12820
|
+
}
|
12805
12821
|
const lambda = await createLambdaFromPseudoLayers(options);
|
12806
12822
|
const isPPR = experimental.ppr && group.isAppRouter && !group.isAppRouteHandler;
|
12807
12823
|
let revalidate;
|
@@ -12827,6 +12843,9 @@ async function serverBuild({
|
|
12827
12843
|
});
|
12828
12844
|
}
|
12829
12845
|
let outputName = import_path4.default.posix.join(entryDirectory, pageName);
|
12846
|
+
if (group.isActionPrerender) {
|
12847
|
+
outputName = `${outputName}.action`;
|
12848
|
+
}
|
12830
12849
|
if (isPPR) {
|
12831
12850
|
if (!revalidate) {
|
12832
12851
|
throw new Error("Invariant: PPR lambda isn't set");
|
@@ -13366,6 +13385,70 @@ async function serverBuild({
|
|
13366
13385
|
override: true
|
13367
13386
|
}
|
13368
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
|
+
] : [],
|
13369
13452
|
{
|
13370
13453
|
src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
|
13371
13454
|
has: [
|
@@ -13798,7 +13881,6 @@ var build = async ({
|
|
13798
13881
|
meta = {}
|
13799
13882
|
}) => {
|
13800
13883
|
validateEntrypoint(entrypoint);
|
13801
|
-
const lambdaCompressedByteLimit = config.maxLambdaSize || 50 * MIB;
|
13802
13884
|
let entryDirectory = import_path5.default.dirname(entrypoint);
|
13803
13885
|
let entryPath = import_path5.default.join(workPath, entryDirectory);
|
13804
13886
|
if (config.rootDirectory) {
|
@@ -13903,6 +13985,20 @@ var build = async ({
|
|
13903
13985
|
} else {
|
13904
13986
|
await (0, import_build_utils3.runNpmInstall)(entryPath, [], spawnOpts, meta, nodeVersion);
|
13905
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
|
+
}
|
13906
14002
|
const nextVersion = getRealNextVersion(entryPath);
|
13907
14003
|
if (!nextVersion) {
|
13908
14004
|
throw new import_build_utils3.NowBuildError({
|
@@ -14657,7 +14753,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
14657
14753
|
escapedBuildId,
|
14658
14754
|
outputDirectory,
|
14659
14755
|
trailingSlashRedirects,
|
14660
|
-
lambdaCompressedByteLimit,
|
14661
14756
|
requiredServerFilesManifest,
|
14662
14757
|
privateOutputs,
|
14663
14758
|
hasIsr404Page,
|
@@ -14829,7 +14924,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
14829
14924
|
tracedPseudoLayer: tracedPseudoLayer?.pseudoLayer || {},
|
14830
14925
|
initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
|
14831
14926
|
initialPseudoLayerUncompressed: 0,
|
14832
|
-
lambdaCompressedByteLimit,
|
14833
14927
|
// internal pages are already referenced in traces for serverless
|
14834
14928
|
// like builds
|
14835
14929
|
internalPages: [],
|
@@ -14846,7 +14940,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
14846
14940
|
tracedPseudoLayer: tracedPseudoLayer?.pseudoLayer || {},
|
14847
14941
|
initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
|
14848
14942
|
initialPseudoLayerUncompressed: 0,
|
14849
|
-
lambdaCompressedByteLimit,
|
14850
14943
|
internalPages: [],
|
14851
14944
|
experimentalPPRRoutes: void 0
|
14852
14945
|
});
|
@@ -14877,7 +14970,6 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
14877
14970
|
];
|
14878
14971
|
await detectLambdaLimitExceeding(
|
14879
14972
|
combinedInitialLambdaGroups,
|
14880
|
-
lambdaCompressedByteLimit,
|
14881
14973
|
compressedPages
|
14882
14974
|
);
|
14883
14975
|
let apiLambdaGroupIndex = 0;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "4.1
|
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",
|
@@ -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.
|
33
|
+
"@vercel/build-utils": "7.11.0",
|
34
34
|
"@vercel/routing-utils": "3.1.0",
|
35
35
|
"async-sema": "3.0.1",
|
36
36
|
"buffer-crc32": "0.2.13",
|