@vercel/next 4.2.4 → 4.2.6

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 +81 -12
  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;
@@ -14309,6 +14321,7 @@ var CORRECT_NOT_FOUND_ROUTES_VERSION = "v12.0.1";
14309
14321
  var CORRECT_MIDDLEWARE_ORDER_VERSION = "v12.1.7-canary.29";
14310
14322
  var NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = "v12.1.7-canary.33";
14311
14323
  var EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = "v12.2.0";
14324
+ var ACTION_OUTPUT_SUPPORT_VERSION = "v14.2.2";
14312
14325
  var CORRECTED_MANIFESTS_VERSION = "v12.2.0";
14313
14326
  var PRELOAD_CHUNKS = {
14314
14327
  APP_ROUTER_PAGES: [
@@ -14388,6 +14401,7 @@ async function serverBuild({
14388
14401
  nextVersion,
14389
14402
  EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION
14390
14403
  );
14404
+ const hasActionOutputSupport = import_semver3.default.gte(nextVersion, ACTION_OUTPUT_SUPPORT_VERSION) && Boolean(process.env.NEXT_EXPERIMENTAL_STREAMING_ACTIONS);
14391
14405
  const projectDir = requiredServerFilesManifest.relativeAppDir ? import_path4.default.join(baseDir, requiredServerFilesManifest.relativeAppDir) : requiredServerFilesManifest.appDir || entryPath;
14392
14406
  const inversedAppPathManifest = {};
14393
14407
  if (appPathRoutesManifest) {
@@ -14928,11 +14942,19 @@ async function serverBuild({
14928
14942
  pageExtensions,
14929
14943
  inversedAppPathManifest
14930
14944
  });
14945
+ const appRouterStreamingActionLambdaGroups = [];
14931
14946
  for (const group of appRouterLambdaGroups) {
14932
14947
  if (!group.isPrerenders || group.isExperimentalPPR) {
14933
14948
  group.isStreaming = true;
14934
14949
  }
14935
14950
  group.isAppRouter = true;
14951
+ if (hasActionOutputSupport) {
14952
+ appRouterStreamingActionLambdaGroups.push({
14953
+ ...group,
14954
+ isActionLambda: true,
14955
+ isStreaming: true
14956
+ });
14957
+ }
14936
14958
  }
14937
14959
  for (const group of appRouteHandlersLambdaGroups) {
14938
14960
  if (!group.isPrerenders) {
@@ -14980,6 +15002,12 @@ async function serverBuild({
14980
15002
  pseudoLayerBytes: group.pseudoLayerBytes,
14981
15003
  uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
14982
15004
  })),
15005
+ appRouterStreamingPrerenderLambdaGroups: appRouterStreamingActionLambdaGroups.map((group) => ({
15006
+ pages: group.pages,
15007
+ isPrerender: group.isPrerenders,
15008
+ pseudoLayerBytes: group.pseudoLayerBytes,
15009
+ uncompressedLayerBytes: group.pseudoLayerUncompressedBytes
15010
+ })),
14983
15011
  appRouteHandlersLambdaGroups: appRouteHandlersLambdaGroups.map(
14984
15012
  (group) => ({
14985
15013
  pages: group.pages,
@@ -14997,6 +15025,7 @@ async function serverBuild({
14997
15025
  const combinedGroups = [
14998
15026
  ...pageLambdaGroups,
14999
15027
  ...appRouterLambdaGroups,
15028
+ ...appRouterStreamingActionLambdaGroups,
15000
15029
  ...apiLambdaGroups,
15001
15030
  ...appRouteHandlersLambdaGroups
15002
15031
  ];
@@ -15143,6 +15172,9 @@ async function serverBuild({
15143
15172
  });
15144
15173
  }
15145
15174
  let outputName = import_path4.default.posix.join(entryDirectory, pageName);
15175
+ if (group.isActionLambda) {
15176
+ outputName = `${outputName}.action`;
15177
+ }
15146
15178
  if (isPPR) {
15147
15179
  if (!revalidate) {
15148
15180
  throw new Error("Invariant: PPR lambda isn't set");
@@ -15267,7 +15299,8 @@ async function serverBuild({
15267
15299
  bypassToken: prerenderManifest.bypassToken || "",
15268
15300
  isServerMode: true,
15269
15301
  dynamicMiddlewareRouteMap: middleware.dynamicRouteMap,
15270
- experimentalPPRRoutes
15302
+ experimentalPPRRoutes,
15303
+ hasActionOutputSupport
15271
15304
  }).then(
15272
15305
  (arr) => localizeDynamicRoutes(
15273
15306
  arr,
@@ -15682,6 +15715,40 @@ async function serverBuild({
15682
15715
  override: true
15683
15716
  }
15684
15717
  ] : [],
15718
+ ...hasActionOutputSupport ? [
15719
+ // Create rewrites for streaming prerenders (.action routes)
15720
+ // This contains separate rewrites for each possible "has" (action header, or content-type)
15721
+ // Also includes separate handling for index routes which should match to /index.action.
15722
+ // This follows the same pattern as the rewrites for .rsc files.
15723
+ {
15724
+ src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
15725
+ dest: import_path4.default.posix.join("/", entryDirectory, "/index.action"),
15726
+ has: [
15727
+ {
15728
+ type: "header",
15729
+ key: "next-action"
15730
+ }
15731
+ ],
15732
+ continue: true,
15733
+ override: true
15734
+ },
15735
+ {
15736
+ src: `^${import_path4.default.posix.join(
15737
+ "/",
15738
+ entryDirectory,
15739
+ "/((?!.+\\.action).+?)(?:/)?$"
15740
+ )}`,
15741
+ dest: import_path4.default.posix.join("/", entryDirectory, "/$1.action"),
15742
+ has: [
15743
+ {
15744
+ type: "header",
15745
+ key: "next-action"
15746
+ }
15747
+ ],
15748
+ continue: true,
15749
+ override: true
15750
+ }
15751
+ ] : [],
15685
15752
  {
15686
15753
  src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}`,
15687
15754
  has: [
@@ -17387,7 +17454,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17387
17454
  canUsePreviewMode,
17388
17455
  bypassToken: prerenderManifest.bypassToken || "",
17389
17456
  isServerMode,
17390
- experimentalPPRRoutes
17457
+ experimentalPPRRoutes,
17458
+ hasActionOutputSupport: false
17391
17459
  }).then(
17392
17460
  (arr) => localizeDynamicRoutes(
17393
17461
  arr,
@@ -17413,7 +17481,8 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
17413
17481
  canUsePreviewMode,
17414
17482
  bypassToken: prerenderManifest.bypassToken || "",
17415
17483
  isServerMode,
17416
- experimentalPPRRoutes
17484
+ experimentalPPRRoutes,
17485
+ hasActionOutputSupport: false
17417
17486
  }).then(
17418
17487
  (arr) => arr.map((route) => {
17419
17488
  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.6",
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",