@vercel/next 4.2.11 → 4.2.12
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 +56 -43
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -11971,7 +11971,9 @@ function normalizePage(page) {
|
|
11971
11971
|
if (!page.startsWith("/")) {
|
11972
11972
|
page = `/${page}`;
|
11973
11973
|
}
|
11974
|
-
page
|
11974
|
+
if (page === "/index") {
|
11975
|
+
page = "/";
|
11976
|
+
}
|
11975
11977
|
return page;
|
11976
11978
|
}
|
11977
11979
|
async function getRoutesManifest(entryPath, outputDirectory, nextVersion) {
|
@@ -12017,8 +12019,8 @@ async function getDynamicRoutes({
|
|
12017
12019
|
bypassToken,
|
12018
12020
|
isServerMode,
|
12019
12021
|
dynamicMiddlewareRouteMap,
|
12020
|
-
|
12021
|
-
|
12022
|
+
hasActionOutputSupport,
|
12023
|
+
isAppPPREnabled
|
12022
12024
|
}) {
|
12023
12025
|
if (routesManifest) {
|
12024
12026
|
switch (routesManifest.version) {
|
@@ -12072,7 +12074,7 @@ async function getDynamicRoutes({
|
|
12072
12074
|
}
|
12073
12075
|
];
|
12074
12076
|
}
|
12075
|
-
if (
|
12077
|
+
if (isAppPPREnabled) {
|
12076
12078
|
let dest = route.dest?.replace(/($|\?)/, ".prefetch.rsc$1");
|
12077
12079
|
if (page === "/" || page === "/index") {
|
12078
12080
|
dest = dest?.replace(/([^/]+\.prefetch\.rsc(\?.*|$))/, "__$1");
|
@@ -12716,6 +12718,7 @@ async function getPageLambdaGroups({
|
|
12716
12718
|
const routeName = normalizePage(page.replace(/\.js$/, ""));
|
12717
12719
|
const isPrerenderRoute = prerenderRoutes.has(routeName);
|
12718
12720
|
const isExperimentalPPR = experimentalPPRRoutes?.has(routeName) ?? false;
|
12721
|
+
const isStreaming = !isPrerenderRoute || isExperimentalPPR;
|
12719
12722
|
let opts = {};
|
12720
12723
|
if (functionsConfigManifest && functionsConfigManifest.functions[routeName]) {
|
12721
12724
|
opts = functionsConfigManifest.functions[routeName];
|
@@ -12762,6 +12765,7 @@ async function getPageLambdaGroups({
|
|
12762
12765
|
...opts,
|
12763
12766
|
isPrerenders: isPrerenderRoute,
|
12764
12767
|
isExperimentalPPR,
|
12768
|
+
isStreaming,
|
12765
12769
|
isApiLambda: !!isApiPage(page),
|
12766
12770
|
pseudoLayerBytes: initialPseudoLayer.pseudoLayerBytes,
|
12767
12771
|
pseudoLayerUncompressedBytes: initialPseudoLayerUncompressed,
|
@@ -13128,14 +13132,6 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
|
|
13128
13132
|
if (isOmittedOrNotFound) {
|
13129
13133
|
initialStatus = 404;
|
13130
13134
|
}
|
13131
|
-
let addedIndexSuffix = false;
|
13132
|
-
if (isAppPathRoute) {
|
13133
|
-
if (routeKey !== "/index" && routeKey.endsWith("/index")) {
|
13134
|
-
routeKey = `${routeKey}/index`;
|
13135
|
-
routeFileNoExt = routeKey;
|
13136
|
-
addedIndexSuffix = true;
|
13137
|
-
}
|
13138
|
-
}
|
13139
13135
|
let outputPathPage = import_path2.default.posix.join(entryDirectory, routeFileNoExt);
|
13140
13136
|
if (!isAppPathRoute) {
|
13141
13137
|
outputPathPage = normalizeIndexOutput(outputPathPage, isServerMode);
|
@@ -13260,7 +13256,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
|
|
13260
13256
|
);
|
13261
13257
|
}
|
13262
13258
|
experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
|
13263
|
-
pathnameToOutputName(entryDirectory, routeKey
|
13259
|
+
pathnameToOutputName(entryDirectory, routeKey)
|
13264
13260
|
);
|
13265
13261
|
if (!experimentalStreamingLambdaPath && srcRoute) {
|
13266
13262
|
experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
|
@@ -13439,11 +13435,9 @@ function normalizeIndexOutput(outputName, isServerMode) {
|
|
13439
13435
|
function getNextServerPath(nextVersion) {
|
13440
13436
|
return import_semver.default.gte(nextVersion, "v11.0.2-canary.4") ? "next/dist/server" : "next/dist/next-server/server";
|
13441
13437
|
}
|
13442
|
-
function pathnameToOutputName(entryDirectory, pathname
|
13438
|
+
function pathnameToOutputName(entryDirectory, pathname) {
|
13443
13439
|
if (pathname === "/") {
|
13444
13440
|
pathname = "/index";
|
13445
|
-
} else if (addedIndexSuffix) {
|
13446
|
-
pathname = pathname.replace(/\/index$/, "");
|
13447
13441
|
}
|
13448
13442
|
return import_path2.default.posix.join(entryDirectory, pathname);
|
13449
13443
|
}
|
@@ -14423,8 +14417,15 @@ async function serverBuild({
|
|
14423
14417
|
isCorrectLocaleAPIRoutes,
|
14424
14418
|
requiredServerFilesManifest,
|
14425
14419
|
variantsManifest,
|
14426
|
-
experimentalPPRRoutes
|
14420
|
+
experimentalPPRRoutes,
|
14421
|
+
isAppPPREnabled
|
14427
14422
|
}) {
|
14423
|
+
if (isAppPPREnabled) {
|
14424
|
+
(0, import_build_utils2.debug)(
|
14425
|
+
"experimentalPPRRoutes",
|
14426
|
+
JSON.stringify(Array.from(experimentalPPRRoutes))
|
14427
|
+
);
|
14428
|
+
}
|
14428
14429
|
lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
|
14429
14430
|
const experimentalAllowBundling = Boolean(
|
14430
14431
|
process.env.NEXT_EXPERIMENTAL_FUNCTION_BUNDLING
|
@@ -14446,16 +14447,13 @@ async function serverBuild({
|
|
14446
14447
|
inversedAppPathManifest[appPathRoutesManifest[ogRoute]] = ogRoute;
|
14447
14448
|
}
|
14448
14449
|
}
|
14449
|
-
const experimental = {
|
14450
|
-
ppr: requiredServerFilesManifest.config.experimental?.ppr === true || requiredServerFilesManifest.config.experimental?.ppr === "incremental"
|
14451
|
-
};
|
14452
14450
|
let appRscPrefetches = {};
|
14453
14451
|
let appBuildTraces = {};
|
14454
14452
|
let appDir = null;
|
14455
14453
|
if (appPathRoutesManifest) {
|
14456
14454
|
appDir = import_path4.default.join(pagesDir, "../app");
|
14457
14455
|
appBuildTraces = await (0, import_build_utils2.glob)("**/*.js.nft.json", appDir);
|
14458
|
-
appRscPrefetches =
|
14456
|
+
appRscPrefetches = isAppPPREnabled ? {} : await (0, import_build_utils2.glob)(`**/*${RSC_PREFETCH_SUFFIX}`, appDir);
|
14459
14457
|
const rscContentTypeHeader = routesManifest?.rsc?.contentTypeHeader || RSC_CONTENT_TYPE;
|
14460
14458
|
appRscPrefetches = normalizePrefetches(appRscPrefetches);
|
14461
14459
|
for (const value of Object.values(appRscPrefetches)) {
|
@@ -14467,7 +14465,7 @@ async function serverBuild({
|
|
14467
14465
|
if (rewrite.src && rewrite.dest) {
|
14468
14466
|
rewrite.src = rewrite.src.replace(
|
14469
14467
|
/\/?\(\?:\/\)\?/,
|
14470
|
-
`(?<rscsuff>${
|
14468
|
+
`(?<rscsuff>${isAppPPREnabled ? "(\\.prefetch)?" : ""}\\.rsc)?(?:/)?`
|
14471
14469
|
);
|
14472
14470
|
let destQueryIndex = rewrite.dest.indexOf("?");
|
14473
14471
|
if (destQueryIndex === -1) {
|
@@ -14981,9 +14979,6 @@ async function serverBuild({
|
|
14981
14979
|
});
|
14982
14980
|
const appRouterStreamingActionLambdaGroups = [];
|
14983
14981
|
for (const group of appRouterLambdaGroups) {
|
14984
|
-
if (!group.isPrerenders || group.isExperimentalPPR) {
|
14985
|
-
group.isStreaming = true;
|
14986
|
-
}
|
14987
14982
|
group.isAppRouter = true;
|
14988
14983
|
if (hasActionOutputSupport) {
|
14989
14984
|
appRouterStreamingActionLambdaGroups.push({
|
@@ -14994,9 +14989,6 @@ async function serverBuild({
|
|
14994
14989
|
}
|
14995
14990
|
}
|
14996
14991
|
for (const group of appRouteHandlersLambdaGroups) {
|
14997
|
-
if (!group.isPrerenders) {
|
14998
|
-
group.isStreaming = true;
|
14999
|
-
}
|
15000
14992
|
group.isAppRouter = true;
|
15001
14993
|
group.isAppRouteHandler = true;
|
15002
14994
|
}
|
@@ -15024,24 +15016,32 @@ async function serverBuild({
|
|
15024
15016
|
apiLambdaGroups: apiLambdaGroups.map((group) => ({
|
15025
15017
|
pages: group.pages,
|
15026
15018
|
isPrerender: group.isPrerenders,
|
15019
|
+
isStreaming: group.isStreaming,
|
15020
|
+
isExperimentalPPR: group.isExperimentalPPR,
|
15027
15021
|
pseudoLayerBytes: group.pseudoLayerBytes,
|
15028
15022
|
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
15029
15023
|
})),
|
15030
15024
|
pageLambdaGroups: pageLambdaGroups.map((group) => ({
|
15031
15025
|
pages: group.pages,
|
15032
15026
|
isPrerender: group.isPrerenders,
|
15027
|
+
isStreaming: group.isStreaming,
|
15028
|
+
isExperimentalPPR: group.isExperimentalPPR,
|
15033
15029
|
pseudoLayerBytes: group.pseudoLayerBytes,
|
15034
15030
|
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
15035
15031
|
})),
|
15036
15032
|
appRouterLambdaGroups: appRouterLambdaGroups.map((group) => ({
|
15037
15033
|
pages: group.pages,
|
15038
15034
|
isPrerender: group.isPrerenders,
|
15035
|
+
isStreaming: group.isStreaming,
|
15036
|
+
isExperimentalPPR: group.isExperimentalPPR,
|
15039
15037
|
pseudoLayerBytes: group.pseudoLayerBytes,
|
15040
15038
|
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
15041
15039
|
})),
|
15042
15040
|
appRouterStreamingPrerenderLambdaGroups: appRouterStreamingActionLambdaGroups.map((group) => ({
|
15043
15041
|
pages: group.pages,
|
15044
15042
|
isPrerender: group.isPrerenders,
|
15043
|
+
isStreaming: group.isStreaming,
|
15044
|
+
isExperimentalPPR: group.isExperimentalPPR,
|
15045
15045
|
pseudoLayerBytes: group.pseudoLayerBytes,
|
15046
15046
|
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
15047
15047
|
})),
|
@@ -15049,6 +15049,8 @@ async function serverBuild({
|
|
15049
15049
|
(group) => ({
|
15050
15050
|
pages: group.pages,
|
15051
15051
|
isPrerender: group.isPrerenders,
|
15052
|
+
isStreaming: group.isStreaming,
|
15053
|
+
isExperimentalPPR: group.isExperimentalPPR,
|
15052
15054
|
pseudoLayerBytes: group.pseudoLayerBytes,
|
15053
15055
|
uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
|
15054
15056
|
})
|
@@ -15185,9 +15187,8 @@ async function serverBuild({
|
|
15185
15187
|
options.layers.push(appNotFoundPsuedoLayer.pseudoLayer);
|
15186
15188
|
}
|
15187
15189
|
const lambda = await createLambdaFromPseudoLayers(options);
|
15188
|
-
const isPPR = experimental.ppr && group.isAppRouter && !group.isAppRouteHandler;
|
15189
15190
|
let revalidate;
|
15190
|
-
if (
|
15191
|
+
if (group.isExperimentalPPR) {
|
15191
15192
|
if (!options.isStreaming) {
|
15192
15193
|
throw new Error("Invariant: PPR lambda isn't streaming");
|
15193
15194
|
}
|
@@ -15198,9 +15199,9 @@ async function serverBuild({
|
|
15198
15199
|
}
|
15199
15200
|
for (const pageFilename of group.pages) {
|
15200
15201
|
const pageName = pageFilename.replace(/\.js$/, "");
|
15201
|
-
const
|
15202
|
-
const pagePathname = pagePath === "/index" ? "/" : pagePath;
|
15202
|
+
const pagePathname = normalizePage(pageName);
|
15203
15203
|
let isPrerender = prerenderRoutes.has(pagePathname);
|
15204
|
+
const isRoutePPREnabled = experimentalPPRRoutes.has(pagePathname);
|
15204
15205
|
if (!isPrerender && routesManifest?.i18n) {
|
15205
15206
|
isPrerender = routesManifest.i18n.locales.some((locale) => {
|
15206
15207
|
return prerenderRoutes.has(
|
@@ -15212,7 +15213,7 @@ async function serverBuild({
|
|
15212
15213
|
if (group.isActionLambda) {
|
15213
15214
|
outputName = `${outputName}.action`;
|
15214
15215
|
}
|
15215
|
-
if (
|
15216
|
+
if (isRoutePPREnabled) {
|
15216
15217
|
if (!revalidate) {
|
15217
15218
|
throw new Error("Invariant: PPR lambda isn't set");
|
15218
15219
|
}
|
@@ -15261,6 +15262,12 @@ async function serverBuild({
|
|
15261
15262
|
}
|
15262
15263
|
console.timeEnd(lambdaCreationLabel);
|
15263
15264
|
}
|
15265
|
+
if (isAppPPREnabled) {
|
15266
|
+
(0, import_build_utils2.debug)(
|
15267
|
+
"experimentalStreamingLambdaPaths",
|
15268
|
+
JSON.stringify(Array.from(experimentalStreamingLambdaPaths))
|
15269
|
+
);
|
15270
|
+
}
|
15264
15271
|
const prerenderRoute = onPrerenderRoute({
|
15265
15272
|
appDir,
|
15266
15273
|
pagesDir,
|
@@ -15336,7 +15343,7 @@ async function serverBuild({
|
|
15336
15343
|
bypassToken: prerenderManifest.bypassToken || "",
|
15337
15344
|
isServerMode: true,
|
15338
15345
|
dynamicMiddlewareRouteMap: middleware.dynamicRouteMap,
|
15339
|
-
|
15346
|
+
isAppPPREnabled,
|
15340
15347
|
hasActionOutputSupport
|
15341
15348
|
}).then(
|
15342
15349
|
(arr) => localizeDynamicRoutes(
|
@@ -15489,13 +15496,13 @@ async function serverBuild({
|
|
15489
15496
|
);
|
15490
15497
|
if (lambdas[pathname]) {
|
15491
15498
|
lambdas[`${pathname}.rsc`] = lambdas[pathname];
|
15492
|
-
if (
|
15499
|
+
if (isAppPPREnabled) {
|
15493
15500
|
lambdas[`${pathname}${RSC_PREFETCH_SUFFIX}`] = lambdas[pathname];
|
15494
15501
|
}
|
15495
15502
|
}
|
15496
15503
|
if (edgeFunctions[pathname]) {
|
15497
15504
|
edgeFunctions[`${pathname}.rsc`] = edgeFunctions[pathname];
|
15498
|
-
if (
|
15505
|
+
if (isAppPPREnabled) {
|
15499
15506
|
edgeFunctions[`${pathname}${RSC_PREFETCH_SUFFIX}`] = edgeFunctions[pathname];
|
15500
15507
|
}
|
15501
15508
|
if (hasActionOutputSupport) {
|
@@ -15508,10 +15515,10 @@ async function serverBuild({
|
|
15508
15515
|
const rscPrefetchHeader = routesManifest.rsc?.prefetchHeader?.toLowerCase();
|
15509
15516
|
const rscVaryHeader = routesManifest?.rsc?.varyHeader || "RSC, Next-Router-State-Tree, Next-Router-Prefetch";
|
15510
15517
|
const appNotFoundPath = import_path4.default.posix.join(".", entryDirectory, "_not-found");
|
15511
|
-
if (
|
15518
|
+
if (isAppPPREnabled && !rscPrefetchHeader) {
|
15512
15519
|
throw new Error("Invariant: cannot use PPR without 'rsc.prefetchHeader'");
|
15513
15520
|
}
|
15514
|
-
if (
|
15521
|
+
if (isAppPPREnabled) {
|
15515
15522
|
for (const { srcRoute, dataRoute, experimentalPPR } of Object.values(
|
15516
15523
|
prerenderManifest.staticRoutes
|
15517
15524
|
)) {
|
@@ -15721,7 +15728,7 @@ async function serverBuild({
|
|
15721
15728
|
// to prevent a local/deploy mismatch
|
15722
15729
|
...!isCorrectMiddlewareOrder ? middleware.staticRoutes : [],
|
15723
15730
|
...appDir ? [
|
15724
|
-
...rscPrefetchHeader &&
|
15731
|
+
...rscPrefetchHeader && isAppPPREnabled ? [
|
15725
15732
|
{
|
15726
15733
|
src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
|
15727
15734
|
has: [
|
@@ -16239,10 +16246,14 @@ var build = async ({
|
|
16239
16246
|
const nextVersionRange = await getNextVersionRange(entryPath);
|
16240
16247
|
const nodeVersion = await (0, import_build_utils3.getNodeVersion)(entryPath, void 0, config, meta);
|
16241
16248
|
const spawnOpts = (0, import_build_utils3.getSpawnOptions)(meta, nodeVersion);
|
16242
|
-
const { cliType, lockfileVersion } = await (0, import_build_utils3.scanParentDirs)(
|
16249
|
+
const { cliType, lockfileVersion, packageJson } = await (0, import_build_utils3.scanParentDirs)(
|
16250
|
+
entryPath,
|
16251
|
+
true
|
16252
|
+
);
|
16243
16253
|
spawnOpts.env = (0, import_build_utils3.getEnvForPackageManager)({
|
16244
16254
|
cliType,
|
16245
16255
|
lockfileVersion,
|
16256
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
16246
16257
|
nodeVersion,
|
16247
16258
|
env: spawnOpts.env || {}
|
16248
16259
|
});
|
@@ -17031,6 +17042,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
17031
17042
|
continue;
|
17032
17043
|
experimentalPPRRoutes.add(route);
|
17033
17044
|
}
|
17045
|
+
const isAppPPREnabled = requiredServerFilesManifest ? requiredServerFilesManifest.config.experimental?.ppr === true || requiredServerFilesManifest.config.experimental?.ppr === "incremental" : false;
|
17034
17046
|
if (requiredServerFilesManifest) {
|
17035
17047
|
if (!routesManifest) {
|
17036
17048
|
throw new Error(
|
@@ -17078,7 +17090,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
17078
17090
|
hasIsr404Page,
|
17079
17091
|
hasIsr500Page,
|
17080
17092
|
variantsManifest,
|
17081
|
-
experimentalPPRRoutes
|
17093
|
+
experimentalPPRRoutes,
|
17094
|
+
isAppPPREnabled
|
17082
17095
|
});
|
17083
17096
|
}
|
17084
17097
|
const pageKeys = Object.keys(pages);
|
@@ -17474,7 +17487,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
17474
17487
|
canUsePreviewMode,
|
17475
17488
|
bypassToken: prerenderManifest.bypassToken || "",
|
17476
17489
|
isServerMode,
|
17477
|
-
|
17490
|
+
isAppPPREnabled: false,
|
17478
17491
|
hasActionOutputSupport: false
|
17479
17492
|
}).then(
|
17480
17493
|
(arr) => localizeDynamicRoutes(
|
@@ -17501,7 +17514,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
17501
17514
|
canUsePreviewMode,
|
17502
17515
|
bypassToken: prerenderManifest.bypassToken || "",
|
17503
17516
|
isServerMode,
|
17504
|
-
|
17517
|
+
isAppPPREnabled: false,
|
17505
17518
|
hasActionOutputSupport: false
|
17506
17519
|
}).then(
|
17507
17520
|
(arr) => arr.map((route) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "4.2.
|
3
|
+
"version": "4.2.12",
|
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": "8.
|
33
|
+
"@vercel/build-utils": "8.2.0",
|
34
34
|
"@vercel/routing-utils": "3.1.0",
|
35
35
|
"async-sema": "3.0.1",
|
36
36
|
"buffer-crc32": "0.2.13",
|