@vercel/next 4.7.8 → 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 -8
  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,13 +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}?${Object.entries(
11197
- prefetchSegmentDataRoute.routeKeys ?? routeKeys ?? {}
11198
- ).map(([key, value]) => `${value}=$${key}`).join("&")}`,
11232
+ routeKeys,
11233
+ prefetchSegmentDataRoute
11234
+ ),
11199
11235
  check: true
11200
11236
  });
11201
11237
  }
@@ -11285,6 +11321,13 @@ async function getDynamicRoutes({
11285
11321
  });
11286
11322
  return routes;
11287
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
+ }
11288
11331
  function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes, inversedAppPathRoutesManifest) {
11289
11332
  const finalDynamicRoutes = [];
11290
11333
  const nonLocalePrefixedRoutes = [];
@@ -12267,7 +12310,7 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12267
12310
  let htmlFsRef = null;
12268
12311
  let postponedPrerender;
12269
12312
  let didPostpone = false;
12270
- if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && appDir) {
12313
+ if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && appDir && !isBlocking) {
12271
12314
  const htmlPath = import_path2.default.join(appDir, `${routeFileNoExt}.html`);
12272
12315
  const metaPath = import_path2.default.join(appDir, `${routeFileNoExt}.meta`);
12273
12316
  if (import_fs_extra3.default.existsSync(htmlPath) && import_fs_extra3.default.existsSync(metaPath)) {
@@ -12501,7 +12544,11 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12501
12544
  let htmlAllowQuery = allowQuery;
12502
12545
  if (renderingMode === "PARTIALLY_STATIC" /* PARTIALLY_STATIC */ && (isFallback || isBlocking)) {
12503
12546
  const { fallbackRootParams } = isFallback ? prerenderManifest.fallbackRoutes[routeKey] : prerenderManifest.blockingFallbackRoutes[routeKey];
12504
- htmlAllowQuery = fallbackRootParams ?? [];
12547
+ if (fallbackRootParams && fallbackRootParams.length > 0) {
12548
+ htmlAllowQuery = fallbackRootParams;
12549
+ } else if (postponedPrerender) {
12550
+ htmlAllowQuery = [];
12551
+ }
12505
12552
  }
12506
12553
  prerenders[outputPathPage] = new import_build_utils.Prerender({
12507
12554
  expiration: initialRevalidate,
@@ -14913,6 +14960,10 @@ ${JSON.stringify(
14913
14960
  appPathRoutesManifest: appPathRoutesManifest || {}
14914
14961
  });
14915
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
+ }) : [];
14916
14967
  const dynamicRoutes = await getDynamicRoutes({
14917
14968
  entryPath,
14918
14969
  entryDirectory,
@@ -15661,6 +15712,7 @@ ${JSON.stringify(
15661
15712
  status: 404
15662
15713
  }
15663
15714
  ] : [],
15715
+ ...staticSegmentRoutes,
15664
15716
  // Dynamic routes (must come after dataRoutes as dataRoutes are more
15665
15717
  // specific)
15666
15718
  ...dynamicRoutes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.7.8",
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",