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