@vercel/next 4.10.9 → 4.11.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.
Files changed (2) hide show
  1. package/dist/index.js +56 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10925,6 +10925,7 @@ var MIB = 1024 * KIB;
10925
10925
  var EDGE_FUNCTION_SIZE_LIMIT = 4 * MIB;
10926
10926
  var DEFAULT_MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * MIB;
10927
10927
  var LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 25 * MIB;
10928
+ var INTERNAL_PAGES = ["_app.js", "_error.js", "_document.js"];
10928
10929
 
10929
10930
  // src/edge-function-source/get-edge-function-source.ts
10930
10931
  var import_zlib = __toESM(require("zlib"));
@@ -11161,6 +11162,14 @@ async function getDynamicRoutes({
11161
11162
  case 3:
11162
11163
  case 4: {
11163
11164
  const routes2 = [];
11165
+ if (isAppClientSegmentCacheEnabled && !isAppPPREnabled) {
11166
+ routes2.push({
11167
+ src: "^/(?<path>.+)(?<rscSuffix>\\.segments/.+\\.segment\\.rsc)(?:/)?$",
11168
+ dest: `/$path${isAppPPREnabled ? ".prefetch.rsc" : ".rsc"}`,
11169
+ check: true,
11170
+ override: true
11171
+ });
11172
+ }
11164
11173
  for (const dynamicRoute of routesManifest.dynamicRoutes) {
11165
11174
  if (!canUsePreviewMode && omittedRoutes?.has(dynamicRoute.page)) {
11166
11175
  continue;
@@ -11181,7 +11190,8 @@ async function getDynamicRoutes({
11181
11190
  namedRegex,
11182
11191
  regex,
11183
11192
  routeKeys,
11184
- prefetchSegmentDataRoutes
11193
+ prefetchSegmentDataRoutes,
11194
+ hasFallbackRootParams
11185
11195
  } = params;
11186
11196
  const route = {
11187
11197
  src: namedRegex || regex,
@@ -11190,6 +11200,10 @@ async function getDynamicRoutes({
11190
11200
  if (!isServerMode) {
11191
11201
  route.check = true;
11192
11202
  }
11203
+ if (isAppPPREnabled || isAppClientSegmentCacheEnabled) {
11204
+ route.check = true;
11205
+ route.override = true;
11206
+ }
11193
11207
  if (isServerMode && canUsePreviewMode && omittedRoutes?.has(page)) {
11194
11208
  route.has = [
11195
11209
  {
@@ -11206,7 +11220,6 @@ async function getDynamicRoutes({
11206
11220
  if (isAppClientSegmentCacheEnabled && prefetchSegmentDataRoutes && prefetchSegmentDataRoutes.length > 0) {
11207
11221
  for (const prefetchSegmentDataRoute of prefetchSegmentDataRoutes) {
11208
11222
  routes2.push({
11209
- ...route,
11210
11223
  src: prefetchSegmentDataRoute.source,
11211
11224
  dest: getDestinationForSegmentRoute(
11212
11225
  isDev === true,
@@ -11214,18 +11227,23 @@ async function getDynamicRoutes({
11214
11227
  routeKeys,
11215
11228
  prefetchSegmentDataRoute
11216
11229
  ),
11217
- check: true
11230
+ check: true,
11231
+ override: true
11218
11232
  });
11219
11233
  }
11220
11234
  }
11221
11235
  if (isAppPPREnabled || isAppClientSegmentCacheEnabled) {
11222
11236
  routes2.push({
11223
- ...route,
11224
11237
  src: route.src.replace(
11225
11238
  new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
11226
- "(?<rscSuffix>\\.rsc|\\.prefetch\\.rsc|\\.segments/.+\\.segment\\.rsc)(?:/)?$"
11239
+ hasFallbackRootParams ? "\\.rsc(?:/)?$" : "(?<rscSuffix>\\.rsc|\\.prefetch\\.rsc|\\.segments/.+\\.segment\\.rsc)(?:/)?$"
11240
+ ),
11241
+ dest: route.dest?.replace(
11242
+ /($|\?)/,
11243
+ hasFallbackRootParams ? ".rsc$1" : "$rscSuffix$1"
11227
11244
  ),
11228
- dest: route.dest?.replace(/($|\?)/, "$rscSuffix$1")
11245
+ check: true,
11246
+ override: true
11229
11247
  });
11230
11248
  } else {
11231
11249
  routes2.push({
@@ -11620,7 +11638,13 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11620
11638
  };
11621
11639
  });
11622
11640
  lazyRoutes.forEach((lazyRoute) => {
11623
- const { routeRegex, fallback, dataRoute, dataRouteRegex } = manifest.dynamicRoutes[lazyRoute];
11641
+ const {
11642
+ routeRegex,
11643
+ fallback,
11644
+ dataRoute,
11645
+ dataRouteRegex,
11646
+ fallbackRootParams
11647
+ } = manifest.dynamicRoutes[lazyRoute];
11624
11648
  if (fallback) {
11625
11649
  ret.fallbackRoutes[lazyRoute] = {
11626
11650
  routeRegex,
@@ -11634,6 +11658,8 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11634
11658
  ret.blockingFallbackRoutes[lazyRoute] = {
11635
11659
  routeRegex,
11636
11660
  dataRoute,
11661
+ fallback: null,
11662
+ fallbackRootParams,
11637
11663
  dataRouteRegex,
11638
11664
  renderingMode: "STATIC" /* STATIC */,
11639
11665
  allowHeader: void 0
@@ -11749,7 +11775,8 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11749
11775
  prefetchDataRouteRegex,
11750
11776
  renderingMode,
11751
11777
  allowHeader,
11752
- fallbackRootParams
11778
+ fallbackRootParams,
11779
+ fallback: null
11753
11780
  };
11754
11781
  } else {
11755
11782
  ret.omittedRoutes[lazyRoute] = {
@@ -11856,11 +11883,13 @@ async function getSourceFilePathFromPage({
11856
11883
  if (page === "/_not-found/page") {
11857
11884
  return "";
11858
11885
  }
11859
- console.log(
11860
- `WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(
11861
- ", "
11862
- )}, this can cause functions config from \`vercel.json\` to not be applied`
11863
- );
11886
+ if (!INTERNAL_PAGES.includes(page)) {
11887
+ console.log(
11888
+ `WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(
11889
+ ", "
11890
+ )}, this can cause functions config from \`vercel.json\` to not be applied`
11891
+ );
11892
+ }
11864
11893
  return "";
11865
11894
  }
11866
11895
  function isDirectory(path5) {
@@ -12516,8 +12545,8 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12516
12545
  }
12517
12546
  let htmlAllowQuery = allowQuery;
12518
12547
  if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && (isFallback || isBlocking)) {
12519
- const { fallbackRootParams } = isFallback ? prerenderManifest.fallbackRoutes[routeKey] : prerenderManifest.blockingFallbackRoutes[routeKey];
12520
- if (fallbackRootParams && fallbackRootParams.length > 0) {
12548
+ const { fallbackRootParams, fallback } = isFallback ? prerenderManifest.fallbackRoutes[routeKey] : prerenderManifest.blockingFallbackRoutes[routeKey];
12549
+ if (fallback && typeof fallback === "string" && fallbackRootParams && fallbackRootParams.length > 0) {
12521
12550
  htmlAllowQuery = fallbackRootParams;
12522
12551
  } else if (postponedPrerender) {
12523
12552
  htmlAllowQuery = [];
@@ -13931,7 +13960,7 @@ async function serverBuild({
13931
13960
  const lambdas = {};
13932
13961
  const prerenders = {};
13933
13962
  const lambdaPageKeys = Object.keys(lambdaPages);
13934
- const internalPages = ["_app.js", "_error.js", "_document.js"];
13963
+ const internalPages = [...INTERNAL_PAGES];
13935
13964
  const pageBuildTraces = await (0, import_build_utils2.glob)("**/*.js.nft.json", pagesDir);
13936
13965
  const isEmptyAllowQueryForPrendered = import_semver3.default.gte(
13937
13966
  nextVersion,
@@ -15162,6 +15191,9 @@ ${JSON.stringify(
15162
15191
  lambdas[dataPathname] = lambdas[srcPathname];
15163
15192
  }
15164
15193
  }
15194
+ const shouldHandleSegmentToRsc = Boolean(
15195
+ isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix
15196
+ );
15165
15197
  return {
15166
15198
  wildcard: wildcardConfig,
15167
15199
  images: getImagesConfig(imagesManifest),
@@ -15473,7 +15505,8 @@ ${JSON.stringify(
15473
15505
  has: [
15474
15506
  {
15475
15507
  type: "header",
15476
- key: rscHeader
15508
+ key: rscHeader,
15509
+ value: "1"
15477
15510
  }
15478
15511
  ],
15479
15512
  dest: import_path4.default.posix.join("/", entryDirectory, "/index.rsc"),
@@ -15490,7 +15523,8 @@ ${JSON.stringify(
15490
15523
  has: [
15491
15524
  {
15492
15525
  type: "header",
15493
- key: rscHeader
15526
+ key: rscHeader,
15527
+ value: "1"
15494
15528
  }
15495
15529
  ],
15496
15530
  dest: import_path4.default.posix.join("/", entryDirectory, "/$1.rsc"),
@@ -15641,19 +15675,11 @@ ${JSON.stringify(
15641
15675
  }
15642
15676
  ] : [],
15643
15677
  // If it didn't match any of the static routes or dynamic ones, then we
15644
- // should fallback to the regular RSC request.
15645
- ...isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix ? [
15678
+ // should fallback to either prefetch or normal RSC request
15679
+ ...shouldHandleSegmentToRsc && prefetchSegmentDirSuffix && prefetchSegmentSuffix ? [
15646
15680
  {
15647
- src: import_path4.default.posix.join(
15648
- "/",
15649
- entryDirectory,
15650
- `/(?<path>.+)${(0, import_escape_string_regexp2.default)(prefetchSegmentDirSuffix)}/.+${(0, import_escape_string_regexp2.default)(prefetchSegmentSuffix)}$`
15651
- ),
15652
- dest: import_path4.default.posix.join(
15653
- "/",
15654
- entryDirectory,
15655
- isAppPPREnabled ? "/$path.prefetch.rsc" : "/$path.rsc"
15656
- ),
15681
+ src: "^/(?<path>.+)(?<rscSuffix>\\.segments/.+\\.segment\\.rsc)(?:/)?$",
15682
+ dest: `/$path${isAppPPREnabled ? ".prefetch.rsc" : ".rsc"}`,
15657
15683
  check: true
15658
15684
  }
15659
15685
  ] : [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.10.9",
3
+ "version": "4.11.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",