@vercel/next 4.3.10 → 4.3.11

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 +98 -50
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -11114,7 +11114,8 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11114
11114
  ret.staticRoutes[route] = {
11115
11115
  initialRevalidate: initialRevalidateSeconds === false ? false : Math.max(1, initialRevalidateSeconds),
11116
11116
  dataRoute,
11117
- srcRoute
11117
+ srcRoute,
11118
+ renderingMode: "STATIC" /* STATIC */
11118
11119
  };
11119
11120
  });
11120
11121
  lazyRoutes.forEach((lazyRoute) => {
@@ -11124,13 +11125,15 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11124
11125
  routeRegex,
11125
11126
  fallback,
11126
11127
  dataRoute,
11127
- dataRouteRegex
11128
+ dataRouteRegex,
11129
+ renderingMode: "STATIC" /* STATIC */
11128
11130
  };
11129
11131
  } else {
11130
11132
  ret.blockingFallbackRoutes[lazyRoute] = {
11131
11133
  routeRegex,
11132
11134
  dataRoute,
11133
- dataRouteRegex
11135
+ dataRouteRegex,
11136
+ renderingMode: "STATIC" /* STATIC */
11134
11137
  };
11135
11138
  }
11136
11139
  });
@@ -11158,14 +11161,16 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11158
11161
  let initialStatus;
11159
11162
  let initialHeaders;
11160
11163
  let experimentalBypassFor;
11161
- let experimentalPPR;
11162
11164
  let prefetchDataRoute;
11165
+ let renderingMode;
11163
11166
  if (manifest.version === 4) {
11164
11167
  initialStatus = manifest.routes[route].initialStatus;
11165
11168
  initialHeaders = manifest.routes[route].initialHeaders;
11166
11169
  experimentalBypassFor = manifest.routes[route].experimentalBypassFor;
11167
- experimentalPPR = manifest.routes[route].experimentalPPR;
11168
11170
  prefetchDataRoute = manifest.routes[route].prefetchDataRoute;
11171
+ renderingMode = manifest.routes[route].renderingMode ?? (manifest.routes[route].experimentalPPR ? "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ : "STATIC" /* STATIC */);
11172
+ } else {
11173
+ renderingMode = "STATIC" /* STATIC */;
11169
11174
  }
11170
11175
  ret.staticRoutes[route] = {
11171
11176
  initialRevalidate: initialRevalidateSeconds === false ? false : Math.max(1, initialRevalidateSeconds),
@@ -11175,29 +11180,30 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11175
11180
  initialStatus,
11176
11181
  initialHeaders,
11177
11182
  experimentalBypassFor,
11178
- experimentalPPR
11183
+ renderingMode
11179
11184
  };
11180
11185
  });
11181
11186
  lazyRoutes.forEach((lazyRoute) => {
11182
11187
  const { routeRegex, fallback, dataRoute, dataRouteRegex } = manifest.dynamicRoutes[lazyRoute];
11183
11188
  let experimentalBypassFor;
11184
- let experimentalPPR;
11185
11189
  let prefetchDataRoute;
11186
11190
  let prefetchDataRouteRegex;
11187
11191
  let fallbackStatus;
11188
11192
  let fallbackHeaders;
11193
+ let renderingMode = "STATIC" /* STATIC */;
11189
11194
  if (manifest.version === 4) {
11190
11195
  experimentalBypassFor = manifest.dynamicRoutes[lazyRoute].experimentalBypassFor;
11191
- experimentalPPR = manifest.dynamicRoutes[lazyRoute].experimentalPPR;
11192
11196
  prefetchDataRoute = manifest.dynamicRoutes[lazyRoute].prefetchDataRoute;
11193
11197
  prefetchDataRouteRegex = manifest.dynamicRoutes[lazyRoute].prefetchDataRouteRegex;
11194
11198
  fallbackStatus = manifest.dynamicRoutes[lazyRoute].fallbackStatus;
11195
11199
  fallbackHeaders = manifest.dynamicRoutes[lazyRoute].fallbackHeaders;
11200
+ renderingMode = manifest.dynamicRoutes[lazyRoute].renderingMode ?? // By default, when the rendering mode isn't specified, fallback to
11201
+ // using the `experimentalPPR` flag.
11202
+ (manifest.dynamicRoutes[lazyRoute].experimentalPPR ? "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ : "STATIC" /* STATIC */);
11196
11203
  }
11197
11204
  if (typeof fallback === "string") {
11198
11205
  ret.fallbackRoutes[lazyRoute] = {
11199
11206
  experimentalBypassFor,
11200
- experimentalPPR,
11201
11207
  routeRegex,
11202
11208
  fallback,
11203
11209
  fallbackStatus,
@@ -11205,27 +11211,28 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
11205
11211
  dataRoute,
11206
11212
  dataRouteRegex,
11207
11213
  prefetchDataRoute,
11208
- prefetchDataRouteRegex
11214
+ prefetchDataRouteRegex,
11215
+ renderingMode
11209
11216
  };
11210
11217
  } else if (fallback === null) {
11211
11218
  ret.blockingFallbackRoutes[lazyRoute] = {
11212
11219
  experimentalBypassFor,
11213
- experimentalPPR,
11214
11220
  routeRegex,
11215
11221
  dataRoute,
11216
11222
  dataRouteRegex,
11217
11223
  prefetchDataRoute,
11218
- prefetchDataRouteRegex
11224
+ prefetchDataRouteRegex,
11225
+ renderingMode
11219
11226
  };
11220
11227
  } else {
11221
11228
  ret.omittedRoutes[lazyRoute] = {
11222
11229
  experimentalBypassFor,
11223
- experimentalPPR,
11224
11230
  routeRegex,
11225
11231
  dataRoute,
11226
11232
  dataRouteRegex,
11227
11233
  prefetchDataRoute,
11228
- prefetchDataRouteRegex
11234
+ prefetchDataRouteRegex,
11235
+ renderingMode
11229
11236
  };
11230
11237
  }
11231
11238
  });
@@ -11671,7 +11678,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11671
11678
  let initialStatus;
11672
11679
  let initialHeaders;
11673
11680
  let experimentalBypassFor;
11674
- let experimentalPPR;
11681
+ let renderingMode;
11675
11682
  if (isFallback || isBlocking) {
11676
11683
  const pr = isFallback ? prerenderManifest.fallbackRoutes[routeKey] : prerenderManifest.blockingFallbackRoutes[routeKey];
11677
11684
  initialRevalidate = 1;
@@ -11684,14 +11691,14 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11684
11691
  srcRoute = null;
11685
11692
  dataRoute = pr.dataRoute;
11686
11693
  experimentalBypassFor = pr.experimentalBypassFor;
11687
- experimentalPPR = pr.experimentalPPR;
11694
+ renderingMode = pr.renderingMode;
11688
11695
  prefetchDataRoute = pr.prefetchDataRoute;
11689
11696
  } else if (isOmitted) {
11690
11697
  initialRevalidate = false;
11691
11698
  srcRoute = routeKey;
11692
11699
  dataRoute = prerenderManifest.omittedRoutes[routeKey].dataRoute;
11693
11700
  experimentalBypassFor = prerenderManifest.omittedRoutes[routeKey].experimentalBypassFor;
11694
- experimentalPPR = prerenderManifest.omittedRoutes[routeKey].experimentalPPR;
11701
+ renderingMode = prerenderManifest.omittedRoutes[routeKey].renderingMode;
11695
11702
  prefetchDataRoute = prerenderManifest.omittedRoutes[routeKey].prefetchDataRoute;
11696
11703
  } else {
11697
11704
  const pr = prerenderManifest.staticRoutes[routeKey];
@@ -11702,12 +11709,12 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11702
11709
  initialHeaders,
11703
11710
  initialStatus,
11704
11711
  experimentalBypassFor,
11705
- experimentalPPR,
11712
+ renderingMode,
11706
11713
  prefetchDataRoute
11707
11714
  } = pr);
11708
11715
  }
11709
11716
  let isAppPathRoute = false;
11710
- if (appDir && experimentalPPR) {
11717
+ if (appDir && renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */) {
11711
11718
  isAppPathRoute = true;
11712
11719
  if (isFallback) {
11713
11720
  const { fallbackStatus, fallbackHeaders } = prerenderManifest.fallbackRoutes[routeKey];
@@ -11725,7 +11732,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11725
11732
  const isOmittedOrNotFound = isOmitted || isNotFound;
11726
11733
  let htmlFsRef = null;
11727
11734
  let postponedPrerender;
11728
- if (experimentalPPR && appDir) {
11735
+ if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && appDir) {
11729
11736
  const htmlPath = import_path2.default.join(appDir, `${routeFileNoExt}.html`);
11730
11737
  const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
11731
11738
  if (import_fs_extra3.default.existsSync(htmlPath) && import_fs_extra3.default.existsSync(metaPath)) {
@@ -11797,7 +11804,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11797
11804
  // be from the prefetch data route. If this isn't enabled
11798
11805
  // for ppr, the only way to get the data is from the data
11799
11806
  // route.
11800
- experimentalPPR ? prefetchDataRoute : dataRoute
11807
+ renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ ? prefetchDataRoute : dataRoute
11801
11808
  ) : routeFileNoExt + ".json"}`
11802
11809
  )
11803
11810
  })
@@ -11839,7 +11846,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11839
11846
  );
11840
11847
  }
11841
11848
  outputPathPrefetchData = normalizeDataRoute(prefetchDataRoute);
11842
- } else if (experimentalPPR) {
11849
+ } else if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */) {
11843
11850
  throw new Error("Invariant: expected to find prefetch data route PPR");
11844
11851
  }
11845
11852
  if (isSharedLambdas) {
@@ -11881,7 +11888,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11881
11888
  if (outputPathPrefetchData) {
11882
11889
  prerenders[outputPathPrefetchData] = jsonFsRef;
11883
11890
  }
11884
- if (outputPathData && !experimentalPPR) {
11891
+ if (outputPathData && renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */) {
11885
11892
  prerenders[outputPathData] = jsonFsRef;
11886
11893
  }
11887
11894
  }
@@ -11923,26 +11930,34 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11923
11930
  if (`/${outputPathPage}` !== srcRoute && srcRoute) {
11924
11931
  sourcePath = srcRoute;
11925
11932
  }
11933
+ let chain;
11926
11934
  let experimentalStreamingLambdaPath;
11927
- if (experimentalPPR) {
11928
- if (!experimentalStreamingLambdaPaths) {
11929
- throw new Error(
11930
- "Invariant: experimentalStreamingLambdaPaths doesn't exist"
11931
- );
11932
- }
11933
- experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
11935
+ if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && experimentalStreamingLambdaPaths) {
11936
+ let paths = experimentalStreamingLambdaPaths.get(
11934
11937
  pathnameToOutputName(entryDirectory, routeKey)
11935
11938
  );
11936
- if (!experimentalStreamingLambdaPath && srcRoute) {
11937
- experimentalStreamingLambdaPath = experimentalStreamingLambdaPaths.get(
11939
+ if (!paths && srcRoute) {
11940
+ paths = experimentalStreamingLambdaPaths.get(
11938
11941
  pathnameToOutputName(entryDirectory, srcRoute)
11939
11942
  );
11940
11943
  }
11941
- if (!experimentalStreamingLambdaPath) {
11944
+ if (!paths) {
11942
11945
  throw new Error(
11943
11946
  `Invariant: experimentalStreamingLambdaPath is undefined for routeKey=${routeKey} and srcRoute=${srcRoute ?? "null"}`
11944
11947
  );
11945
11948
  }
11949
+ experimentalStreamingLambdaPath = paths.output;
11950
+ if (routesManifest?.ppr?.chain?.headers) {
11951
+ chain = {
11952
+ outputPath: pathnameToOutputName(entryDirectory, routeKey),
11953
+ headers: routesManifest.ppr.chain.headers
11954
+ };
11955
+ } else {
11956
+ chain = {
11957
+ outputPath: paths.output,
11958
+ headers: { "x-matched-path": paths.pathname }
11959
+ };
11960
+ }
11946
11961
  }
11947
11962
  prerenders[outputPathPage] = new import_build_utils.Prerender({
11948
11963
  expiration: initialRevalidate,
@@ -11956,6 +11971,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
11956
11971
  initialHeaders,
11957
11972
  sourcePath,
11958
11973
  experimentalStreamingLambdaPath,
11974
+ chain,
11959
11975
  ...isNotFound ? {
11960
11976
  initialStatus: 404
11961
11977
  } : {},
@@ -12004,7 +12020,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12004
12020
  if (outputPathPrefetchData) {
12005
12021
  prerenders[normalizePathData(outputPathPrefetchData)] = prerender;
12006
12022
  }
12007
- if (outputPathData && !experimentalPPR) {
12023
+ if (outputPathData && renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */) {
12008
12024
  prerenders[normalizePathData(outputPathData)] = prerender;
12009
12025
  }
12010
12026
  }
@@ -12127,7 +12143,12 @@ function pathnameToOutputName(entryDirectory, pathname) {
12127
12143
  }
12128
12144
  return import_path2.default.posix.join(entryDirectory, pathname);
12129
12145
  }
12130
- function getPostponeResumePathname(entryDirectory, pathname) {
12146
+ function getPostponeResumePathname(pathname) {
12147
+ if (pathname === "/")
12148
+ pathname = "/index";
12149
+ return import_path2.default.posix.join("_next/postponed/resume", pathname);
12150
+ }
12151
+ function getPostponeResumeOutput(entryDirectory, pathname) {
12131
12152
  if (pathname === "/")
12132
12153
  pathname = "/index";
12133
12154
  return import_path2.default.posix.join(entryDirectory, "_next/postponed/resume", pathname);
@@ -13901,25 +13922,28 @@ ${JSON.stringify(
13901
13922
  }
13902
13923
  lambdas[outputName] = lambda;
13903
13924
  if (!omittedPrerenderRoutes.has(pagePathname)) {
13904
- const key = getPostponeResumePathname(entryDirectory, pageName);
13905
- lambdas[key] = lambda;
13906
- experimentalStreamingLambdaPaths.set(outputName, key);
13925
+ const output = getPostponeResumeOutput(entryDirectory, pageName);
13926
+ lambdas[output] = lambda;
13927
+ experimentalStreamingLambdaPaths.set(outputName, {
13928
+ pathname: getPostponeResumePathname(pageName),
13929
+ output
13930
+ });
13907
13931
  }
13908
13932
  for (const [
13909
13933
  routePathname,
13910
- { srcRoute, experimentalPPR }
13934
+ { srcRoute, renderingMode }
13911
13935
  ] of Object.entries(prerenderManifest.staticRoutes)) {
13912
- if (srcRoute !== pagePathname || !experimentalPPR)
13936
+ if (srcRoute !== pagePathname || renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */)
13913
13937
  continue;
13914
13938
  if (routePathname === pagePathname)
13915
13939
  continue;
13916
- const key = getPostponeResumePathname(
13917
- entryDirectory,
13918
- routePathname
13919
- );
13920
- lambdas[key] = lambda;
13940
+ const output = getPostponeResumePathname(routePathname);
13941
+ lambdas[output] = lambda;
13921
13942
  outputName = import_path4.default.posix.join(entryDirectory, routePathname);
13922
- experimentalStreamingLambdaPaths.set(outputName, key);
13943
+ experimentalStreamingLambdaPaths.set(outputName, {
13944
+ pathname: getPostponeResumePathname(routePathname),
13945
+ output
13946
+ });
13923
13947
  }
13924
13948
  continue;
13925
13949
  }
@@ -14202,10 +14226,10 @@ ${JSON.stringify(
14202
14226
  throw new Error("Invariant: cannot use PPR without 'rsc.prefetchHeader'");
14203
14227
  }
14204
14228
  if (isAppPPREnabled) {
14205
- for (const { srcRoute, dataRoute, experimentalPPR } of Object.values(
14229
+ for (const { srcRoute, dataRoute, renderingMode } of Object.values(
14206
14230
  prerenderManifest.staticRoutes
14207
14231
  )) {
14208
- if (!experimentalPPR || !dataRoute || !srcRoute)
14232
+ if (renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ || !dataRoute || !srcRoute)
14209
14233
  continue;
14210
14234
  if (!omittedPrerenderRoutes.has(srcRoute))
14211
14235
  continue;
@@ -14263,6 +14287,18 @@ ${JSON.stringify(
14263
14287
  ...i18n ? [
14264
14288
  // Handle auto-adding current default locale to path based on
14265
14289
  // $wildcard
14290
+ // This is split into two rules to avoid matching the `/index` route as it causes issues with trailing slash redirect
14291
+ {
14292
+ src: `^${import_path4.default.posix.join(
14293
+ "/",
14294
+ entryDirectory,
14295
+ "/"
14296
+ )}(?!(?:_next/.*|${i18n.locales.map((locale) => (0, import_escape_string_regexp2.default)(locale)).join("|")})(?:/.*|$))$`,
14297
+ // we aren't able to ensure trailing slash mode here
14298
+ // so ensure this comes after the trailing slash redirect
14299
+ dest: `${entryDirectory !== "." ? import_path4.default.posix.join("/", entryDirectory) : ""}$wildcard${trailingSlash ? "/" : ""}`,
14300
+ continue: true
14301
+ },
14266
14302
  {
14267
14303
  src: `^${import_path4.default.posix.join(
14268
14304
  "/",
@@ -15704,13 +15740,13 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
15704
15740
  }
15705
15741
  }
15706
15742
  const experimentalPPRRoutes = /* @__PURE__ */ new Set();
15707
- for (const [route, { experimentalPPR }] of [
15743
+ for (const [route, { renderingMode }] of [
15708
15744
  ...Object.entries(prerenderManifest.staticRoutes),
15709
15745
  ...Object.entries(prerenderManifest.blockingFallbackRoutes),
15710
15746
  ...Object.entries(prerenderManifest.fallbackRoutes),
15711
15747
  ...Object.entries(prerenderManifest.omittedRoutes)
15712
15748
  ]) {
15713
- if (!experimentalPPR)
15749
+ if (renderingMode !== "PARTIALLY_STATIC" /* PARTIALLY_STATIC */)
15714
15750
  continue;
15715
15751
  experimentalPPRRoutes.add(route);
15716
15752
  }
@@ -16499,6 +16535,18 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
16499
16535
  ...i18n ? [
16500
16536
  // Handle auto-adding current default locale to path based on
16501
16537
  // $wildcard
16538
+ // This is split into two rules to avoid matching the `/index` route as it causes issues with trailing slash redirect
16539
+ {
16540
+ src: `^${import_path5.default.posix.join(
16541
+ "/",
16542
+ entryDirectory,
16543
+ "/"
16544
+ )}(?!(?:_next/.*|${i18n.locales.map((locale) => (0, import_escape_string_regexp3.default)(locale)).join("|")})(?:/.*|$))$`,
16545
+ // we aren't able to ensure trailing slash mode here
16546
+ // so ensure this comes after the trailing slash redirect
16547
+ dest: `${entryDirectory !== "." ? import_path5.default.posix.join("/", entryDirectory) : ""}$wildcard${trailingSlash ? "/" : ""}`,
16548
+ continue: true
16549
+ },
16502
16550
  {
16503
16551
  src: `^${import_path5.default.join(
16504
16552
  "/",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.3.10",
3
+ "version": "4.3.11",
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.4.2",
33
+ "@vercel/build-utils": "8.4.5",
34
34
  "@vercel/routing-utils": "3.1.0",
35
35
  "async-sema": "3.0.1",
36
36
  "buffer-crc32": "0.2.13",