@vercel/next 4.2.11 → 4.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +63 -47
  2. 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 = page.replace(/\/index$/, "/");
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
- experimentalPPRRoutes,
12021
- hasActionOutputSupport
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 (experimentalPPRRoutes.has(page)) {
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,
@@ -12968,7 +12972,8 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12968
12972
  pageLambdaMap,
12969
12973
  routesManifest,
12970
12974
  isCorrectNotFoundRoutes,
12971
- isEmptyAllowQueryForPrendered
12975
+ isEmptyAllowQueryForPrendered,
12976
+ isAppPPREnabled
12972
12977
  } = prerenderRouteArgs;
12973
12978
  if (isBlocking && isFallback) {
12974
12979
  throw new import_build_utils.NowBuildError({
@@ -13128,14 +13133,6 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
13128
13133
  if (isOmittedOrNotFound) {
13129
13134
  initialStatus = 404;
13130
13135
  }
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
13136
  let outputPathPage = import_path2.default.posix.join(entryDirectory, routeFileNoExt);
13140
13137
  if (!isAppPathRoute) {
13141
13138
  outputPathPage = normalizeIndexOutput(outputPathPage, isServerMode);
@@ -13164,7 +13161,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
13164
13161
  }
13165
13162
  let outputPathPrefetchData = null;
13166
13163
  if (prefetchDataRoute) {
13167
- if (!experimentalPPR) {
13164
+ if (!isAppPPREnabled) {
13168
13165
  throw new Error(
13169
13166
  "Invariant: prefetchDataRoute can't be set without PPR"
13170
13167
  );
@@ -13260,7 +13257,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
13260
13257
  );
13261
13258
  }
13262
13259
  experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
13263
- pathnameToOutputName(entryDirectory, routeKey, addedIndexSuffix)
13260
+ pathnameToOutputName(entryDirectory, routeKey)
13264
13261
  );
13265
13262
  if (!experimentalStreamingLambdaPath && srcRoute) {
13266
13263
  experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
@@ -13439,11 +13436,9 @@ function normalizeIndexOutput(outputName, isServerMode) {
13439
13436
  function getNextServerPath(nextVersion) {
13440
13437
  return import_semver.default.gte(nextVersion, "v11.0.2-canary.4") ? "next/dist/server" : "next/dist/next-server/server";
13441
13438
  }
13442
- function pathnameToOutputName(entryDirectory, pathname, addedIndexSuffix = false) {
13439
+ function pathnameToOutputName(entryDirectory, pathname) {
13443
13440
  if (pathname === "/") {
13444
13441
  pathname = "/index";
13445
- } else if (addedIndexSuffix) {
13446
- pathname = pathname.replace(/\/index$/, "");
13447
13442
  }
13448
13443
  return import_path2.default.posix.join(entryDirectory, pathname);
13449
13444
  }
@@ -14423,8 +14418,15 @@ async function serverBuild({
14423
14418
  isCorrectLocaleAPIRoutes,
14424
14419
  requiredServerFilesManifest,
14425
14420
  variantsManifest,
14426
- experimentalPPRRoutes
14421
+ experimentalPPRRoutes,
14422
+ isAppPPREnabled
14427
14423
  }) {
14424
+ if (isAppPPREnabled) {
14425
+ (0, import_build_utils2.debug)(
14426
+ "experimentalPPRRoutes",
14427
+ JSON.stringify(Array.from(experimentalPPRRoutes))
14428
+ );
14429
+ }
14428
14430
  lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
14429
14431
  const experimentalAllowBundling = Boolean(
14430
14432
  process.env.NEXT_EXPERIMENTAL_FUNCTION_BUNDLING
@@ -14446,16 +14448,13 @@ async function serverBuild({
14446
14448
  inversedAppPathManifest[appPathRoutesManifest[ogRoute]] = ogRoute;
14447
14449
  }
14448
14450
  }
14449
- const experimental = {
14450
- ppr: requiredServerFilesManifest.config.experimental?.ppr === true || requiredServerFilesManifest.config.experimental?.ppr === "incremental"
14451
- };
14452
14451
  let appRscPrefetches = {};
14453
14452
  let appBuildTraces = {};
14454
14453
  let appDir = null;
14455
14454
  if (appPathRoutesManifest) {
14456
14455
  appDir = import_path4.default.join(pagesDir, "../app");
14457
14456
  appBuildTraces = await (0, import_build_utils2.glob)("**/*.js.nft.json", appDir);
14458
- appRscPrefetches = experimental.ppr ? {} : await (0, import_build_utils2.glob)(`**/*${RSC_PREFETCH_SUFFIX}`, appDir);
14457
+ appRscPrefetches = isAppPPREnabled ? {} : await (0, import_build_utils2.glob)(`**/*${RSC_PREFETCH_SUFFIX}`, appDir);
14459
14458
  const rscContentTypeHeader = routesManifest?.rsc?.contentTypeHeader || RSC_CONTENT_TYPE;
14460
14459
  appRscPrefetches = normalizePrefetches(appRscPrefetches);
14461
14460
  for (const value of Object.values(appRscPrefetches)) {
@@ -14467,7 +14466,7 @@ async function serverBuild({
14467
14466
  if (rewrite.src && rewrite.dest) {
14468
14467
  rewrite.src = rewrite.src.replace(
14469
14468
  /\/?\(\?:\/\)\?/,
14470
- `(?<rscsuff>${experimental.ppr ? "(\\.prefetch)?" : ""}\\.rsc)?(?:/)?`
14469
+ `(?<rscsuff>${isAppPPREnabled ? "(\\.prefetch)?" : ""}\\.rsc)?(?:/)?`
14471
14470
  );
14472
14471
  let destQueryIndex = rewrite.dest.indexOf("?");
14473
14472
  if (destQueryIndex === -1) {
@@ -14981,9 +14980,6 @@ async function serverBuild({
14981
14980
  });
14982
14981
  const appRouterStreamingActionLambdaGroups = [];
14983
14982
  for (const group of appRouterLambdaGroups) {
14984
- if (!group.isPrerenders || group.isExperimentalPPR) {
14985
- group.isStreaming = true;
14986
- }
14987
14983
  group.isAppRouter = true;
14988
14984
  if (hasActionOutputSupport) {
14989
14985
  appRouterStreamingActionLambdaGroups.push({
@@ -14994,9 +14990,6 @@ async function serverBuild({
14994
14990
  }
14995
14991
  }
14996
14992
  for (const group of appRouteHandlersLambdaGroups) {
14997
- if (!group.isPrerenders) {
14998
- group.isStreaming = true;
14999
- }
15000
14993
  group.isAppRouter = true;
15001
14994
  group.isAppRouteHandler = true;
15002
14995
  }
@@ -15024,24 +15017,32 @@ async function serverBuild({
15024
15017
  apiLambdaGroups: apiLambdaGroups.map((group) => ({
15025
15018
  pages: group.pages,
15026
15019
  isPrerender: group.isPrerenders,
15020
+ isStreaming: group.isStreaming,
15021
+ isExperimentalPPR: group.isExperimentalPPR,
15027
15022
  pseudoLayerBytes: group.pseudoLayerBytes,
15028
15023
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15029
15024
  })),
15030
15025
  pageLambdaGroups: pageLambdaGroups.map((group) => ({
15031
15026
  pages: group.pages,
15032
15027
  isPrerender: group.isPrerenders,
15028
+ isStreaming: group.isStreaming,
15029
+ isExperimentalPPR: group.isExperimentalPPR,
15033
15030
  pseudoLayerBytes: group.pseudoLayerBytes,
15034
15031
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15035
15032
  })),
15036
15033
  appRouterLambdaGroups: appRouterLambdaGroups.map((group) => ({
15037
15034
  pages: group.pages,
15038
15035
  isPrerender: group.isPrerenders,
15036
+ isStreaming: group.isStreaming,
15037
+ isExperimentalPPR: group.isExperimentalPPR,
15039
15038
  pseudoLayerBytes: group.pseudoLayerBytes,
15040
15039
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15041
15040
  })),
15042
15041
  appRouterStreamingPrerenderLambdaGroups: appRouterStreamingActionLambdaGroups.map((group) => ({
15043
15042
  pages: group.pages,
15044
15043
  isPrerender: group.isPrerenders,
15044
+ isStreaming: group.isStreaming,
15045
+ isExperimentalPPR: group.isExperimentalPPR,
15045
15046
  pseudoLayerBytes: group.pseudoLayerBytes,
15046
15047
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15047
15048
  })),
@@ -15049,6 +15050,8 @@ async function serverBuild({
15049
15050
  (group) => ({
15050
15051
  pages: group.pages,
15051
15052
  isPrerender: group.isPrerenders,
15053
+ isStreaming: group.isStreaming,
15054
+ isExperimentalPPR: group.isExperimentalPPR,
15052
15055
  pseudoLayerBytes: group.pseudoLayerBytes,
15053
15056
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15054
15057
  })
@@ -15185,9 +15188,8 @@ async function serverBuild({
15185
15188
  options.layers.push(appNotFoundPsuedoLayer.pseudoLayer);
15186
15189
  }
15187
15190
  const lambda = await createLambdaFromPseudoLayers(options);
15188
- const isPPR = experimental.ppr && group.isAppRouter && !group.isAppRouteHandler;
15189
15191
  let revalidate;
15190
- if (isPPR) {
15192
+ if (group.isExperimentalPPR) {
15191
15193
  if (!options.isStreaming) {
15192
15194
  throw new Error("Invariant: PPR lambda isn't streaming");
15193
15195
  }
@@ -15198,9 +15200,9 @@ async function serverBuild({
15198
15200
  }
15199
15201
  for (const pageFilename of group.pages) {
15200
15202
  const pageName = pageFilename.replace(/\.js$/, "");
15201
- const pagePath = import_path4.default.posix.join("/", pageName);
15202
- const pagePathname = pagePath === "/index" ? "/" : pagePath;
15203
+ const pagePathname = normalizePage(pageName);
15203
15204
  let isPrerender = prerenderRoutes.has(pagePathname);
15205
+ const isRoutePPREnabled = experimentalPPRRoutes.has(pagePathname);
15204
15206
  if (!isPrerender && routesManifest?.i18n) {
15205
15207
  isPrerender = routesManifest.i18n.locales.some((locale) => {
15206
15208
  return prerenderRoutes.has(
@@ -15212,7 +15214,7 @@ async function serverBuild({
15212
15214
  if (group.isActionLambda) {
15213
15215
  outputName = `${outputName}.action`;
15214
15216
  }
15215
- if (isPPR) {
15217
+ if (isRoutePPREnabled) {
15216
15218
  if (!revalidate) {
15217
15219
  throw new Error("Invariant: PPR lambda isn't set");
15218
15220
  }
@@ -15261,6 +15263,12 @@ async function serverBuild({
15261
15263
  }
15262
15264
  console.timeEnd(lambdaCreationLabel);
15263
15265
  }
15266
+ if (isAppPPREnabled) {
15267
+ (0, import_build_utils2.debug)(
15268
+ "experimentalStreamingLambdaPaths",
15269
+ JSON.stringify(Array.from(experimentalStreamingLambdaPaths))
15270
+ );
15271
+ }
15264
15272
  const prerenderRoute = onPrerenderRoute({
15265
15273
  appDir,
15266
15274
  pagesDir,
@@ -15279,7 +15287,8 @@ async function serverBuild({
15279
15287
  localePrefixed404,
15280
15288
  hasPages404: routesManifest.pages404,
15281
15289
  isCorrectNotFoundRoutes,
15282
- isEmptyAllowQueryForPrendered
15290
+ isEmptyAllowQueryForPrendered,
15291
+ isAppPPREnabled
15283
15292
  });
15284
15293
  await Promise.all(
15285
15294
  Object.keys(prerenderManifest.staticRoutes).map(
@@ -15336,7 +15345,7 @@ async function serverBuild({
15336
15345
  bypassToken: prerenderManifest.bypassToken || "",
15337
15346
  isServerMode: true,
15338
15347
  dynamicMiddlewareRouteMap: middleware.dynamicRouteMap,
15339
- experimentalPPRRoutes,
15348
+ isAppPPREnabled,
15340
15349
  hasActionOutputSupport
15341
15350
  }).then(
15342
15351
  (arr) => localizeDynamicRoutes(
@@ -15489,13 +15498,13 @@ async function serverBuild({
15489
15498
  );
15490
15499
  if (lambdas[pathname]) {
15491
15500
  lambdas[`${pathname}.rsc`] = lambdas[pathname];
15492
- if (experimental.ppr) {
15501
+ if (isAppPPREnabled) {
15493
15502
  lambdas[`${pathname}${RSC_PREFETCH_SUFFIX}`] = lambdas[pathname];
15494
15503
  }
15495
15504
  }
15496
15505
  if (edgeFunctions[pathname]) {
15497
15506
  edgeFunctions[`${pathname}.rsc`] = edgeFunctions[pathname];
15498
- if (experimental.ppr) {
15507
+ if (isAppPPREnabled) {
15499
15508
  edgeFunctions[`${pathname}${RSC_PREFETCH_SUFFIX}`] = edgeFunctions[pathname];
15500
15509
  }
15501
15510
  if (hasActionOutputSupport) {
@@ -15508,10 +15517,10 @@ async function serverBuild({
15508
15517
  const rscPrefetchHeader = routesManifest.rsc?.prefetchHeader?.toLowerCase();
15509
15518
  const rscVaryHeader = routesManifest?.rsc?.varyHeader || "RSC, Next-Router-State-Tree, Next-Router-Prefetch";
15510
15519
  const appNotFoundPath = import_path4.default.posix.join(".", entryDirectory, "_not-found");
15511
- if (experimental.ppr && !rscPrefetchHeader) {
15520
+ if (isAppPPREnabled && !rscPrefetchHeader) {
15512
15521
  throw new Error("Invariant: cannot use PPR without 'rsc.prefetchHeader'");
15513
15522
  }
15514
- if (experimental.ppr) {
15523
+ if (isAppPPREnabled) {
15515
15524
  for (const { srcRoute, dataRoute, experimentalPPR } of Object.values(
15516
15525
  prerenderManifest.staticRoutes
15517
15526
  )) {
@@ -15721,7 +15730,7 @@ async function serverBuild({
15721
15730
  // to prevent a local/deploy mismatch
15722
15731
  ...!isCorrectMiddlewareOrder ? middleware.staticRoutes : [],
15723
15732
  ...appDir ? [
15724
- ...rscPrefetchHeader && experimental.ppr ? [
15733
+ ...rscPrefetchHeader && isAppPPREnabled ? [
15725
15734
  {
15726
15735
  src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
15727
15736
  has: [
@@ -16239,10 +16248,14 @@ var build = async ({
16239
16248
  const nextVersionRange = await getNextVersionRange(entryPath);
16240
16249
  const nodeVersion = await (0, import_build_utils3.getNodeVersion)(entryPath, void 0, config, meta);
16241
16250
  const spawnOpts = (0, import_build_utils3.getSpawnOptions)(meta, nodeVersion);
16242
- const { cliType, lockfileVersion } = await (0, import_build_utils3.scanParentDirs)(entryPath);
16251
+ const { cliType, lockfileVersion, packageJson } = await (0, import_build_utils3.scanParentDirs)(
16252
+ entryPath,
16253
+ true
16254
+ );
16243
16255
  spawnOpts.env = (0, import_build_utils3.getEnvForPackageManager)({
16244
16256
  cliType,
16245
16257
  lockfileVersion,
16258
+ packageJsonPackageManager: packageJson?.packageManager,
16246
16259
  nodeVersion,
16247
16260
  env: spawnOpts.env || {}
16248
16261
  });
@@ -17031,6 +17044,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17031
17044
  continue;
17032
17045
  experimentalPPRRoutes.add(route);
17033
17046
  }
17047
+ const isAppPPREnabled = requiredServerFilesManifest ? requiredServerFilesManifest.config.experimental?.ppr === true || requiredServerFilesManifest.config.experimental?.ppr === "incremental" : false;
17034
17048
  if (requiredServerFilesManifest) {
17035
17049
  if (!routesManifest) {
17036
17050
  throw new Error(
@@ -17078,7 +17092,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17078
17092
  hasIsr404Page,
17079
17093
  hasIsr500Page,
17080
17094
  variantsManifest,
17081
- experimentalPPRRoutes
17095
+ experimentalPPRRoutes,
17096
+ isAppPPREnabled
17082
17097
  });
17083
17098
  }
17084
17099
  const pageKeys = Object.keys(pages);
@@ -17474,7 +17489,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17474
17489
  canUsePreviewMode,
17475
17490
  bypassToken: prerenderManifest.bypassToken || "",
17476
17491
  isServerMode,
17477
- experimentalPPRRoutes,
17492
+ isAppPPREnabled: false,
17478
17493
  hasActionOutputSupport: false
17479
17494
  }).then(
17480
17495
  (arr) => localizeDynamicRoutes(
@@ -17501,7 +17516,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17501
17516
  canUsePreviewMode,
17502
17517
  bypassToken: prerenderManifest.bypassToken || "",
17503
17518
  isServerMode,
17504
- experimentalPPRRoutes,
17519
+ isAppPPREnabled: false,
17505
17520
  hasActionOutputSupport: false
17506
17521
  }).then(
17507
17522
  (arr) => arr.map((route) => {
@@ -17680,7 +17695,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17680
17695
  prerenderManifest,
17681
17696
  appPathRoutesManifest,
17682
17697
  isSharedLambdas,
17683
- canUsePreviewMode
17698
+ canUsePreviewMode,
17699
+ isAppPPREnabled: false
17684
17700
  });
17685
17701
  await Promise.all(
17686
17702
  Object.keys(prerenderManifest.staticRoutes).map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.2.11",
3
+ "version": "4.2.13",
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.1.1",
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",