@vercel/next 4.2.4 → 4.2.7

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 -13
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -12017,7 +12017,8 @@ async function getDynamicRoutes({
12017
12017
  bypassToken,
12018
12018
  isServerMode,
12019
12019
  dynamicMiddlewareRouteMap,
12020
- experimentalPPRRoutes
12020
+ experimentalPPRRoutes,
12021
+ hasActionOutputSupport
12021
12022
  }) {
12022
12023
  if (routesManifest) {
12023
12024
  switch (routesManifest.version) {
@@ -12085,14 +12086,25 @@ async function getDynamicRoutes({
12085
12086
  dest
12086
12087
  });
12087
12088
  }
12088
- routes2.push({
12089
- ...route,
12090
- src: route.src.replace(
12091
- new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
12092
- "(?:\\.rsc)(?:/)?$"
12093
- ),
12094
- dest: route.dest?.replace(/($|\?)/, ".rsc$1")
12095
- });
12089
+ if (hasActionOutputSupport) {
12090
+ routes2.push({
12091
+ ...route,
12092
+ src: route.src.replace(
12093
+ new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
12094
+ "(?<nxtsuffix>(?:\\.action|\\.rsc))(?:/)?$"
12095
+ ),
12096
+ dest: route.dest?.replace(/($|\?)/, "$nxtsuffix$1")
12097
+ });
12098
+ } else {
12099
+ routes2.push({
12100
+ ...route,
12101
+ src: route.src.replace(
12102
+ new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
12103
+ "(?:\\.rsc)(?:/)?$"
12104
+ ),
12105
+ dest: route.dest?.replace(/($|\?)/, ".rsc$1")
12106
+ });
12107
+ }
12096
12108
  routes2.push(route);
12097
12109
  }
12098
12110
  return routes2;
@@ -13287,6 +13299,16 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
13287
13299
  } : {}
13288
13300
  });
13289
13301
  }
13302
+ if (outputPrerenderPathData?.endsWith(".json") && appDir) {
13303
+ const dummyOutput = new import_build_utils.FileBlob({
13304
+ data: "{}",
13305
+ contentType: "application/json"
13306
+ });
13307
+ const rscKey = `${outputPathPage}.rsc`;
13308
+ const prefetchRscKey = `${outputPathPage}${RSC_PREFETCH_SUFFIX}`;
13309
+ prerenders[rscKey] = dummyOutput;
13310
+ prerenders[prefetchRscKey] = dummyOutput;
13311
+ }
13290
13312
  ++prerenderGroup;
13291
13313
  if (routesManifest?.i18n && isBlocking) {
13292
13314
  for (const locale2 of routesManifest.i18n.locales) {
@@ -14309,6 +14331,7 @@ var CORRECT_NOT_FOUND_ROUTES_VERSION = "v12.0.1";
14309
14331
  var CORRECT_MIDDLEWARE_ORDER_VERSION = "v12.1.7-canary.29";
14310
14332
  var NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = "v12.1.7-canary.33";
14311
14333
  var EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = "v12.2.0";
14334
+ var ACTION_OUTPUT_SUPPORT_VERSION = "v14.2.2";
14312
14335
  var CORRECTED_MANIFESTS_VERSION = "v12.2.0";
14313
14336
  var PRELOAD_CHUNKS = {
14314
14337
  APP_ROUTER_PAGES: [
@@ -14388,6 +14411,7 @@ async function serverBuild({
14388
14411
  nextVersion,
14389
14412
  EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION
14390
14413
  );
14414
+ const hasActionOutputSupport = import_semver3.default.gte(nextVersion, ACTION_OUTPUT_SUPPORT_VERSION) && Boolean(process.env.NEXT_EXPERIMENTAL_STREAMING_ACTIONS);
14391
14415
  const projectDir = requiredServerFilesManifest.relativeAppDir ? import_path4.default.join(baseDir, requiredServerFilesManifest.relativeAppDir) : requiredServerFilesManifest.appDir || entryPath;
14392
14416
  const inversedAppPathManifest = {};
14393
14417
  if (appPathRoutesManifest) {
@@ -14928,11 +14952,19 @@ async function serverBuild({
14928
14952
  pageExtensions,
14929
14953
  inversedAppPathManifest
14930
14954
  });
14955
+ const appRouterStreamingActionLambdaGroups = [];
14931
14956
  for (const group of appRouterLambdaGroups) {
14932
14957
  if (!group.isPrerenders || group.isExperimentalPPR) {
14933
14958
  group.isStreaming = true;
14934
14959
  }
14935
14960
  group.isAppRouter = true;
14961
+ if (hasActionOutputSupport) {
14962
+ appRouterStreamingActionLambdaGroups.push({
14963
+ ...group,
14964
+ isActionLambda: true,
14965
+ isStreaming: true
14966
+ });
14967
+ }
14936
14968
  }
14937
14969
  for (const group of appRouteHandlersLambdaGroups) {
14938
14970
  if (!group.isPrerenders) {
@@ -14980,6 +15012,12 @@ async function serverBuild({
14980
15012
  pseudoLayerBytes: group.pseudoLayerBytes,
14981
15013
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
14982
15014
  })),
15015
+ appRouterStreamingPrerenderLambdaGroups: appRouterStreamingActionLambdaGroups.map((group) => ({
15016
+ pages: group.pages,
15017
+ isPrerender: group.isPrerenders,
15018
+ pseudoLayerBytes: group.pseudoLayerBytes,
15019
+ uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15020
+ })),
14983
15021
  appRouteHandlersLambdaGroups: appRouteHandlersLambdaGroups.map(
14984
15022
  (group) => ({
14985
15023
  pages: group.pages,
@@ -14997,6 +15035,7 @@ async function serverBuild({
14997
15035
  const combinedGroups = [
14998
15036
  ...pageLambdaGroups,
14999
15037
  ...appRouterLambdaGroups,
15038
+ ...appRouterStreamingActionLambdaGroups,
15000
15039
  ...apiLambdaGroups,
15001
15040
  ...appRouteHandlersLambdaGroups
15002
15041
  ];
@@ -15143,6 +15182,9 @@ async function serverBuild({
15143
15182
  });
15144
15183
  }
15145
15184
  let outputName = import_path4.default.posix.join(entryDirectory, pageName);
15185
+ if (group.isActionLambda) {
15186
+ outputName = `${outputName}.action`;
15187
+ }
15146
15188
  if (isPPR) {
15147
15189
  if (!revalidate) {
15148
15190
  throw new Error("Invariant: PPR lambda isn't set");
@@ -15267,7 +15309,8 @@ async function serverBuild({
15267
15309
  bypassToken: prerenderManifest.bypassToken || "",
15268
15310
  isServerMode: true,
15269
15311
  dynamicMiddlewareRouteMap: middleware.dynamicRouteMap,
15270
- experimentalPPRRoutes
15312
+ experimentalPPRRoutes,
15313
+ hasActionOutputSupport
15271
15314
  }).then(
15272
15315
  (arr) => localizeDynamicRoutes(
15273
15316
  arr,
@@ -15419,9 +15462,15 @@ async function serverBuild({
15419
15462
  );
15420
15463
  if (lambdas[pathname]) {
15421
15464
  lambdas[`${pathname}.rsc`] = lambdas[pathname];
15465
+ if (experimental.ppr) {
15466
+ lambdas[`${pathname}${RSC_PREFETCH_SUFFIX}`] = lambdas[pathname];
15467
+ }
15422
15468
  }
15423
15469
  if (edgeFunctions[pathname]) {
15424
15470
  edgeFunctions[`${pathname}.rsc`] = edgeFunctions[pathname];
15471
+ if (experimental.ppr) {
15472
+ edgeFunctions[`${pathname}${RSC_PREFETCH_SUFFIX}`] = edgeFunctions[pathname];
15473
+ }
15425
15474
  }
15426
15475
  }
15427
15476
  }
@@ -15682,8 +15731,42 @@ async function serverBuild({
15682
15731
  override: true
15683
15732
  }
15684
15733
  ] : [],
15734
+ ...hasActionOutputSupport ? [
15735
+ // Create rewrites for streaming prerenders (.action routes)
15736
+ // This contains separate rewrites for each possible "has" (action header, or content-type)
15737
+ // Also includes separate handling for index routes which should match to /index.action.
15738
+ // This follows the same pattern as the rewrites for .rsc files.
15739
+ {
15740
+ src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
15741
+ dest: import_path4.default.posix.join("/", entryDirectory, "/index.action"),
15742
+ has: [
15743
+ {
15744
+ type: "header",
15745
+ key: "next-action"
15746
+ }
15747
+ ],
15748
+ continue: true,
15749
+ override: true
15750
+ },
15751
+ {
15752
+ src: `^${import_path4.default.posix.join(
15753
+ "/",
15754
+ entryDirectory,
15755
+ "/((?!.+\\.action).+?)(?:/)?$"
15756
+ )}`,
15757
+ dest: import_path4.default.posix.join("/", entryDirectory, "/$1.action"),
15758
+ has: [
15759
+ {
15760
+ type: "header",
15761
+ key: "next-action"
15762
+ }
15763
+ ],
15764
+ continue: true,
15765
+ override: true
15766
+ }
15767
+ ] : [],
15685
15768
  {
15686
- src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
15769
+ src: `^${import_path4.default.posix.join("/", entryDirectory, "/?")}`,
15687
15770
  has: [
15688
15771
  {
15689
15772
  type: "header",
@@ -17387,7 +17470,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17387
17470
  canUsePreviewMode,
17388
17471
  bypassToken: prerenderManifest.bypassToken || "",
17389
17472
  isServerMode,
17390
- experimentalPPRRoutes
17473
+ experimentalPPRRoutes,
17474
+ hasActionOutputSupport: false
17391
17475
  }).then(
17392
17476
  (arr) => localizeDynamicRoutes(
17393
17477
  arr,
@@ -17413,7 +17497,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17413
17497
  canUsePreviewMode,
17414
17498
  bypassToken: prerenderManifest.bypassToken || "",
17415
17499
  isServerMode,
17416
- experimentalPPRRoutes
17500
+ experimentalPPRRoutes,
17501
+ hasActionOutputSupport: false
17417
17502
  }).then(
17418
17503
  (arr) => arr.map((route) => {
17419
17504
  route.src = route.src.replace("^", `^${dynamicPrefix}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.2.4",
3
+ "version": "4.2.7",
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": "7.12.0",
33
+ "@vercel/build-utils": "8.0.0",
34
34
  "@vercel/routing-utils": "3.1.0",
35
35
  "async-sema": "3.0.1",
36
36
  "buffer-crc32": "0.2.13",