@vercel/next 4.14.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +84 -54
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10924,6 +10924,7 @@ var KIB = 1024;
|
|
|
10924
10924
|
var MIB = 1024 * KIB;
|
|
10925
10925
|
var EDGE_FUNCTION_SIZE_LIMIT = 4 * MIB;
|
|
10926
10926
|
var DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * MIB;
|
|
10927
|
+
var DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE_BUN = 150 * MIB;
|
|
10927
10928
|
var LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 25 * MIB;
|
|
10928
10929
|
var INTERNAL_PAGES = ["_app.js", "_error.js", "_document.js"];
|
|
10929
10930
|
|
|
@@ -11115,9 +11116,12 @@ function getAppRouterPathnameFilesMap(files) {
|
|
|
11115
11116
|
var require_ = (0, import_module.createRequire)(__filename);
|
|
11116
11117
|
var RSC_CONTENT_TYPE = "x-component";
|
|
11117
11118
|
var RSC_PREFETCH_SUFFIX = ".prefetch.rsc";
|
|
11118
|
-
|
|
11119
|
-
Number(process.env.MAX_UNCOMPRESSED_LAMBDA_SIZE)
|
|
11120
|
-
|
|
11119
|
+
function getMaxUncompressedLambdaSize(runtime) {
|
|
11120
|
+
if (!isNaN(Number(process.env.MAX_UNCOMPRESSED_LAMBDA_SIZE))) {
|
|
11121
|
+
return Number(process.env.MAX_UNCOMPRESSED_LAMBDA_SIZE);
|
|
11122
|
+
}
|
|
11123
|
+
return runtime.startsWith("bun") ? DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE_BUN : DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE;
|
|
11124
|
+
}
|
|
11121
11125
|
var skipDefaultLocaleRewrite = Boolean(
|
|
11122
11126
|
process.env.NEXT_EXPERIMENTAL_DEFER_DEFAULT_LOCALE_REWRITE
|
|
11123
11127
|
);
|
|
@@ -11962,48 +11966,53 @@ async function usesSrcDirectory(workPath) {
|
|
|
11962
11966
|
async function getSourceFilePathFromPage({
|
|
11963
11967
|
workPath,
|
|
11964
11968
|
page,
|
|
11965
|
-
pageExtensions
|
|
11969
|
+
pageExtensions,
|
|
11970
|
+
nextVersion
|
|
11966
11971
|
}) {
|
|
11967
11972
|
const usesSrcDir = await usesSrcDirectory(workPath);
|
|
11968
11973
|
const extensionsToTry = pageExtensions || ["js", "jsx", "ts", "tsx"];
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
}
|
|
11980
|
-
const extensionless = fsPath.replace(import_path3.default.extname(fsPath), "");
|
|
11981
|
-
for (const ext of extensionsToTry) {
|
|
11982
|
-
fsPath = `${extensionless}.${ext}`;
|
|
11983
|
-
if (pageType === "app" && extensionless === import_path3.default.join(workPath, `${usesSrcDir ? "src/" : ""}app/index`)) {
|
|
11984
|
-
fsPath = `${extensionless.replace(/index$/, "page")}.${ext}`;
|
|
11974
|
+
const isNextJs16Plus = nextVersion && import_semver.default.gte(nextVersion, "16.0.0");
|
|
11975
|
+
const pagesToCheck = page === "middleware" && isNextJs16Plus ? ["proxy", "middleware"] : [page];
|
|
11976
|
+
for (const pageToCheck of pagesToCheck) {
|
|
11977
|
+
for (const pageType of [
|
|
11978
|
+
// middleware/proxy is not nested in pages/app
|
|
11979
|
+
...pageToCheck === "middleware" || pageToCheck === "proxy" ? [""] : ["pages", "app"]
|
|
11980
|
+
]) {
|
|
11981
|
+
let fsPath = import_path3.default.join(workPath, pageType, pageToCheck);
|
|
11982
|
+
if (usesSrcDir) {
|
|
11983
|
+
fsPath = import_path3.default.join(workPath, "src", pageType, pageToCheck);
|
|
11985
11984
|
}
|
|
11986
11985
|
if (import_fs_extra3.default.existsSync(fsPath)) {
|
|
11987
11986
|
return import_path3.default.relative(workPath, fsPath);
|
|
11988
11987
|
}
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
fsPath =
|
|
11994
|
-
if (import_fs_extra3.default.existsSync(fsPath)) {
|
|
11995
|
-
return import_path3.default.relative(workPath, fsPath);
|
|
11996
|
-
}
|
|
11988
|
+
const extensionless = fsPath.replace(import_path3.default.extname(fsPath), "");
|
|
11989
|
+
for (const ext of extensionsToTry) {
|
|
11990
|
+
fsPath = `${extensionless}.${ext}`;
|
|
11991
|
+
if (pageType === "app" && extensionless === import_path3.default.join(workPath, `${usesSrcDir ? "src/" : ""}app/index`)) {
|
|
11992
|
+
fsPath = `${extensionless.replace(/index$/, "page")}.${ext}`;
|
|
11997
11993
|
}
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
11994
|
+
if (import_fs_extra3.default.existsSync(fsPath)) {
|
|
11995
|
+
return import_path3.default.relative(workPath, fsPath);
|
|
11996
|
+
}
|
|
11997
|
+
}
|
|
11998
|
+
if (isDirectory(extensionless)) {
|
|
11999
|
+
if (pageType === "pages") {
|
|
12000
|
+
for (const ext of extensionsToTry) {
|
|
12001
|
+
fsPath = import_path3.default.join(extensionless, `index.${ext}`);
|
|
12002
|
+
if (import_fs_extra3.default.existsSync(fsPath)) {
|
|
12003
|
+
return import_path3.default.relative(workPath, fsPath);
|
|
12004
|
+
}
|
|
12003
12005
|
}
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12006
|
+
} else {
|
|
12007
|
+
for (const ext of extensionsToTry) {
|
|
12008
|
+
fsPath = import_path3.default.join(extensionless, `page.${ext}`);
|
|
12009
|
+
if (import_fs_extra3.default.existsSync(fsPath)) {
|
|
12010
|
+
return import_path3.default.relative(workPath, fsPath);
|
|
12011
|
+
}
|
|
12012
|
+
fsPath = import_path3.default.join(extensionless, `route.${ext}`);
|
|
12013
|
+
if (import_fs_extra3.default.existsSync(fsPath)) {
|
|
12014
|
+
return import_path3.default.relative(workPath, fsPath);
|
|
12015
|
+
}
|
|
12007
12016
|
}
|
|
12008
12017
|
}
|
|
12009
12018
|
}
|
|
@@ -12015,6 +12024,9 @@ async function getSourceFilePathFromPage({
|
|
|
12015
12024
|
if (page === "/_global-error/page") {
|
|
12016
12025
|
return "";
|
|
12017
12026
|
}
|
|
12027
|
+
if (page === "middleware" && isNextJs16Plus) {
|
|
12028
|
+
return "";
|
|
12029
|
+
}
|
|
12018
12030
|
if (!INTERNAL_PAGES.includes(page)) {
|
|
12019
12031
|
console.log(
|
|
12020
12032
|
`WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(
|
|
@@ -12067,7 +12079,8 @@ async function getPageLambdaGroups({
|
|
|
12067
12079
|
pageExtensions,
|
|
12068
12080
|
inversedAppPathManifest,
|
|
12069
12081
|
experimentalAllowBundling,
|
|
12070
|
-
isRouteHandlers
|
|
12082
|
+
isRouteHandlers,
|
|
12083
|
+
nodeVersion
|
|
12071
12084
|
}) {
|
|
12072
12085
|
const groups = [];
|
|
12073
12086
|
for (const page of pages) {
|
|
@@ -12132,7 +12145,10 @@ async function getPageLambdaGroups({
|
|
|
12132
12145
|
});
|
|
12133
12146
|
newTracedFilesUncompressedSize += compressedPages[newPage].uncompressedSize;
|
|
12134
12147
|
}
|
|
12135
|
-
const
|
|
12148
|
+
const maxLambdaSize = getMaxUncompressedLambdaSize(
|
|
12149
|
+
nodeVersion.runtime
|
|
12150
|
+
);
|
|
12151
|
+
const underUncompressedLimit = newTracedFilesUncompressedSize < maxLambdaSize - LAMBDA_RESERVED_UNCOMPRESSED_SIZE;
|
|
12136
12152
|
return underUncompressedLimit;
|
|
12137
12153
|
}
|
|
12138
12154
|
return false;
|
|
@@ -12251,13 +12267,14 @@ var outputFunctionFileSizeInfo = (pages, pseudoLayer, pseudoLayerUncompressedByt
|
|
|
12251
12267
|
})
|
|
12252
12268
|
);
|
|
12253
12269
|
};
|
|
12254
|
-
var detectLambdaLimitExceeding = async (lambdaGroups, compressedPages) => {
|
|
12255
|
-
const
|
|
12270
|
+
var detectLambdaLimitExceeding = async (lambdaGroups, compressedPages, runtime) => {
|
|
12271
|
+
const maxLambdaSize = getMaxUncompressedLambdaSize(runtime);
|
|
12272
|
+
const UNCOMPRESSED_SIZE_LIMIT_CLOSE = maxLambdaSize - 5 * MIB;
|
|
12256
12273
|
let numExceededLimit = 0;
|
|
12257
12274
|
let numCloseToLimit = 0;
|
|
12258
12275
|
let loggedHeadInfo = false;
|
|
12259
12276
|
const filteredGroups = lambdaGroups.filter((group) => {
|
|
12260
|
-
const exceededLimit = group.pseudoLayerUncompressedBytes >
|
|
12277
|
+
const exceededLimit = group.pseudoLayerUncompressedBytes > maxLambdaSize;
|
|
12261
12278
|
const closeToLimit = group.pseudoLayerUncompressedBytes > UNCOMPRESSED_SIZE_LIMIT_CLOSE;
|
|
12262
12279
|
if (closeToLimit || exceededLimit || (0, import_build_utils.getPlatformEnv)("BUILDER_DEBUG") || process.env.NEXT_DEBUG_FUNCTION_SIZE) {
|
|
12263
12280
|
if (exceededLimit) {
|
|
@@ -12274,7 +12291,7 @@ var detectLambdaLimitExceeding = async (lambdaGroups, compressedPages) => {
|
|
|
12274
12291
|
if (numExceededLimit || numCloseToLimit) {
|
|
12275
12292
|
console.log(
|
|
12276
12293
|
`Warning: Max serverless function size of ${prettyBytes(
|
|
12277
|
-
|
|
12294
|
+
maxLambdaSize
|
|
12278
12295
|
)} uncompressed${numExceededLimit ? "" : " almost"} reached`
|
|
12279
12296
|
);
|
|
12280
12297
|
} else {
|
|
@@ -13143,7 +13160,8 @@ async function getNodeMiddleware({
|
|
|
13143
13160
|
const sourceFile = await getSourceFilePathFromPage({
|
|
13144
13161
|
workPath: entryPath,
|
|
13145
13162
|
page: normalizeSourceFilePageFromManifest("/middleware", "middleware", {}),
|
|
13146
|
-
pageExtensions
|
|
13163
|
+
pageExtensions,
|
|
13164
|
+
nextVersion
|
|
13147
13165
|
});
|
|
13148
13166
|
const vercelConfigOpts = await (0, import_build_utils.getLambdaOptionsFromFunction)({
|
|
13149
13167
|
sourceFile,
|
|
@@ -14613,10 +14631,11 @@ async function serverBuild({
|
|
|
14613
14631
|
2
|
|
14614
14632
|
)
|
|
14615
14633
|
);
|
|
14616
|
-
|
|
14634
|
+
const maxLambdaSize = getMaxUncompressedLambdaSize(nodeVersion.runtime);
|
|
14635
|
+
if (uncompressedInitialSize > maxLambdaSize) {
|
|
14617
14636
|
console.log(
|
|
14618
14637
|
`Warning: Max serverless function size of ${(0, import_pretty_bytes3.default)(
|
|
14619
|
-
|
|
14638
|
+
maxLambdaSize
|
|
14620
14639
|
)} uncompressed reached`
|
|
14621
14640
|
);
|
|
14622
14641
|
outputFunctionFileSizeInfo(
|
|
@@ -14626,7 +14645,7 @@ async function serverBuild({
|
|
|
14626
14645
|
{}
|
|
14627
14646
|
);
|
|
14628
14647
|
throw new import_build_utils2.NowBuildError({
|
|
14629
|
-
message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${
|
|
14648
|
+
message: `Required files read using Node.js fs library and node_modules exceed max lambda size of ${maxLambdaSize} bytes`,
|
|
14630
14649
|
code: "NEXT_REQUIRED_FILES_LIMIT",
|
|
14631
14650
|
link: "https://vercel.com/docs/platform/limits#serverless-function-size"
|
|
14632
14651
|
});
|
|
@@ -14788,7 +14807,8 @@ ${JSON.stringify(
|
|
|
14788
14807
|
initialPseudoLayer,
|
|
14789
14808
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
|
14790
14809
|
internalPages,
|
|
14791
|
-
pageExtensions
|
|
14810
|
+
pageExtensions,
|
|
14811
|
+
nodeVersion
|
|
14792
14812
|
});
|
|
14793
14813
|
for (const group of pageLambdaGroups) {
|
|
14794
14814
|
group.isPages = true;
|
|
@@ -14808,7 +14828,8 @@ ${JSON.stringify(
|
|
|
14808
14828
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
|
14809
14829
|
internalPages,
|
|
14810
14830
|
pageExtensions,
|
|
14811
|
-
inversedAppPathManifest
|
|
14831
|
+
inversedAppPathManifest,
|
|
14832
|
+
nodeVersion
|
|
14812
14833
|
});
|
|
14813
14834
|
const appRouteHandlersLambdaGroups = await getPageLambdaGroups({
|
|
14814
14835
|
experimentalAllowBundling,
|
|
@@ -14826,7 +14847,8 @@ ${JSON.stringify(
|
|
|
14826
14847
|
internalPages,
|
|
14827
14848
|
pageExtensions,
|
|
14828
14849
|
inversedAppPathManifest,
|
|
14829
|
-
isRouteHandlers: true
|
|
14850
|
+
isRouteHandlers: true,
|
|
14851
|
+
nodeVersion
|
|
14830
14852
|
});
|
|
14831
14853
|
const appRouterStreamingActionLambdaGroups = [];
|
|
14832
14854
|
for (const group of appRouterLambdaGroups) {
|
|
@@ -14853,7 +14875,8 @@ ${JSON.stringify(
|
|
|
14853
14875
|
initialPseudoLayer,
|
|
14854
14876
|
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
|
14855
14877
|
internalPages,
|
|
14856
|
-
pageExtensions
|
|
14878
|
+
pageExtensions,
|
|
14879
|
+
nodeVersion
|
|
14857
14880
|
});
|
|
14858
14881
|
for (const group of apiLambdaGroups) {
|
|
14859
14882
|
group.isApiLambda = true;
|
|
@@ -14916,7 +14939,11 @@ ${JSON.stringify(
|
|
|
14916
14939
|
...apiLambdaGroups,
|
|
14917
14940
|
...appRouteHandlersLambdaGroups
|
|
14918
14941
|
];
|
|
14919
|
-
await detectLambdaLimitExceeding(
|
|
14942
|
+
await detectLambdaLimitExceeding(
|
|
14943
|
+
combinedGroups,
|
|
14944
|
+
compressedPages,
|
|
14945
|
+
nodeVersion.runtime
|
|
14946
|
+
);
|
|
14920
14947
|
const appNotFoundTraces = pageTraces["_not-found.js"];
|
|
14921
14948
|
const appNotFoundPsuedoLayer = appNotFoundTraces && await createPseudoLayer(appNotFoundTraces);
|
|
14922
14949
|
for (const group of combinedGroups) {
|
|
@@ -17419,7 +17446,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
|
17419
17446
|
// internal pages are already referenced in traces for serverless
|
|
17420
17447
|
// like builds
|
|
17421
17448
|
internalPages: [],
|
|
17422
|
-
experimentalPPRRoutes: void 0
|
|
17449
|
+
experimentalPPRRoutes: void 0,
|
|
17450
|
+
nodeVersion
|
|
17423
17451
|
});
|
|
17424
17452
|
const initialApiLambdaGroups = await getPageLambdaGroups({
|
|
17425
17453
|
entryPath,
|
|
@@ -17433,7 +17461,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
|
17433
17461
|
initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
|
|
17434
17462
|
initialPseudoLayerUncompressed: 0,
|
|
17435
17463
|
internalPages: [],
|
|
17436
|
-
experimentalPPRRoutes: void 0
|
|
17464
|
+
experimentalPPRRoutes: void 0,
|
|
17465
|
+
nodeVersion
|
|
17437
17466
|
});
|
|
17438
17467
|
for (const group of initialApiLambdaGroups) {
|
|
17439
17468
|
group.isApiLambda = true;
|
|
@@ -17462,7 +17491,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
|
17462
17491
|
];
|
|
17463
17492
|
await detectLambdaLimitExceeding(
|
|
17464
17493
|
combinedInitialLambdaGroups,
|
|
17465
|
-
compressedPages
|
|
17494
|
+
compressedPages,
|
|
17495
|
+
nodeVersion.runtime
|
|
17466
17496
|
);
|
|
17467
17497
|
let apiLambdaGroupIndex = 0;
|
|
17468
17498
|
let nonApiLambdaGroupIndex = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/next",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@types/semver": "6.0.0",
|
|
31
31
|
"@types/text-table": "0.2.1",
|
|
32
32
|
"@types/webpack-sources": "3.2.0",
|
|
33
|
-
"@vercel/build-utils": "12.2.
|
|
34
|
-
"@vercel/routing-utils": "5.2.
|
|
33
|
+
"@vercel/build-utils": "12.2.3",
|
|
34
|
+
"@vercel/routing-utils": "5.2.1",
|
|
35
35
|
"async-sema": "3.0.1",
|
|
36
36
|
"buffer-crc32": "0.2.13",
|
|
37
37
|
"bytes": "3.1.2",
|