@vercel/next 4.7.7 → 4.7.9

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 +60 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11112,6 +11112,43 @@ async function getRoutesManifest(entryPath, outputDirectory, nextVersion) {
11112
11112
  }
11113
11113
  return routesManifest;
11114
11114
  }
11115
+ async function getStaticSegmentRoutes({
11116
+ entryDirectory,
11117
+ routesManifest
11118
+ }) {
11119
+ switch (routesManifest.version) {
11120
+ case 3:
11121
+ case 4: {
11122
+ const routes = [];
11123
+ for (const {
11124
+ routeKeys,
11125
+ prefetchSegmentDataRoutes
11126
+ } of routesManifest.staticRoutes) {
11127
+ if (prefetchSegmentDataRoutes && prefetchSegmentDataRoutes.length > 0) {
11128
+ for (const prefetchSegmentDataRoute of prefetchSegmentDataRoutes) {
11129
+ routes.push({
11130
+ src: prefetchSegmentDataRoute.source,
11131
+ dest: getDestinationForSegmentRoute(
11132
+ false,
11133
+ entryDirectory,
11134
+ routeKeys,
11135
+ prefetchSegmentDataRoute
11136
+ ),
11137
+ check: true
11138
+ });
11139
+ }
11140
+ }
11141
+ }
11142
+ return routes;
11143
+ }
11144
+ default: {
11145
+ throw new import_build_utils.NowBuildError({
11146
+ message: "This version of `@vercel/next` does not support the version of Next.js you are trying to deploy.\nPlease upgrade your `@vercel/next` builder and try again. Contact support if this continues to happen.",
11147
+ code: "NEXT_VERSION_UPGRADE"
11148
+ });
11149
+ }
11150
+ }
11151
+ }
11115
11152
  async function getDynamicRoutes({
11116
11153
  entryPath,
11117
11154
  entryDirectory,
@@ -11189,11 +11226,12 @@ async function getDynamicRoutes({
11189
11226
  routes2.push({
11190
11227
  ...route,
11191
11228
  src: prefetchSegmentDataRoute.source,
11192
- dest: `${!isDev ? import_path2.default.posix.join(
11193
- "/",
11229
+ dest: getDestinationForSegmentRoute(
11230
+ isDev === true,
11194
11231
  entryDirectory,
11195
- prefetchSegmentDataRoute.destination
11196
- ) : prefetchSegmentDataRoute.destination}${routeKeys ? `?${Object.entries(routeKeys).map(([key, value]) => `${value}=$${key}`).join("&")}` : ""}`,
11232
+ routeKeys,
11233
+ prefetchSegmentDataRoute
11234
+ ),
11197
11235
  check: true
11198
11236
  });
11199
11237
  }
@@ -11283,6 +11321,13 @@ async function getDynamicRoutes({
11283
11321
  });
11284
11322
  return routes;
11285
11323
  }
11324
+ function getDestinationForSegmentRoute(isDev, entryDirectory, routeKeys, prefetchSegmentDataRoute) {
11325
+ return `${!isDev ? import_path2.default.posix.join(
11326
+ "/",
11327
+ entryDirectory,
11328
+ prefetchSegmentDataRoute.destination
11329
+ ) : prefetchSegmentDataRoute.destination}?${Object.entries(prefetchSegmentDataRoute.routeKeys ?? routeKeys ?? {}).map(([key, value]) => `${value}=$${key}`).join("&")}`;
11330
+ }
11286
11331
  function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes, inversedAppPathRoutesManifest) {
11287
11332
  const finalDynamicRoutes = [];
11288
11333
  const nonLocalePrefixedRoutes = [];
@@ -12265,7 +12310,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12265
12310
  let htmlFsRef = null;
12266
12311
  let postponedPrerender;
12267
12312
  let didPostpone = false;
12268
- if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && appDir) {
12313
+ if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && appDir && !isBlocking) {
12269
12314
  const htmlPath = import_path2.default.join(appDir, `${routeFileNoExt}.html`);
12270
12315
  const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
12271
12316
  if (import_fs_extra3.default.existsSync(htmlPath) && import_fs_extra3.default.existsSync(metaPath)) {
@@ -12499,7 +12544,11 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12499
12544
  let htmlAllowQuery = allowQuery;
12500
12545
  if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && (isFallback || isBlocking)) {
12501
12546
  const { fallbackRootParams } = isFallback ? prerenderManifest.fallbackRoutes[routeKey] : prerenderManifest.blockingFallbackRoutes[routeKey];
12502
- htmlAllowQuery = fallbackRootParams ?? [];
12547
+ if (fallbackRootParams && fallbackRootParams.length > 0) {
12548
+ htmlAllowQuery = fallbackRootParams;
12549
+ } else if (postponedPrerender) {
12550
+ htmlAllowQuery = [];
12551
+ }
12503
12552
  }
12504
12553
  prerenders[outputPathPage] = new import_build_utils.Prerender({
12505
12554
  expiration: initialRevalidate,
@@ -14911,6 +14960,10 @@ ${JSON.stringify(
14911
14960
  appPathRoutesManifest: appPathRoutesManifest || {}
14912
14961
  });
14913
14962
  const isNextDataServerResolving = (middleware.staticRoutes.length > 0 || nodeMiddleware) && import_semver3.default.gte(nextVersion, NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION);
14963
+ const staticSegmentRoutes = isAppClientSegmentCacheEnabled ? await getStaticSegmentRoutes({
14964
+ entryDirectory,
14965
+ routesManifest
14966
+ }) : [];
14914
14967
  const dynamicRoutes = await getDynamicRoutes({
14915
14968
  entryPath,
14916
14969
  entryDirectory,
@@ -15659,6 +15712,7 @@ ${JSON.stringify(
15659
15712
  status: 404
15660
15713
  }
15661
15714
  ] : [],
15715
+ ...staticSegmentRoutes,
15662
15716
  // Dynamic routes (must come after dataRoutes as dataRoutes are more
15663
15717
  // specific)
15664
15718
  ...dynamicRoutes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.7.7",
3
+ "version": "4.7.9",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",