@vercel/next 4.11.2 → 4.11.3

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 +59 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13472,6 +13472,55 @@ function getHTMLPostponedState({
13472
13472
  }
13473
13473
  return meta.postponed;
13474
13474
  }
13475
+ async function getServerActionMetaRoutes(distDir) {
13476
+ const manifestPath = import_path2.default.join(
13477
+ distDir,
13478
+ "server",
13479
+ "server-reference-manifest.json"
13480
+ );
13481
+ try {
13482
+ const manifestContent = await import_fs_extra3.default.readFile(manifestPath, "utf8");
13483
+ const manifest = JSON.parse(manifestContent);
13484
+ const routes = [];
13485
+ for (const runtimeType of ["node", "edge"]) {
13486
+ const runtime = manifest[runtimeType];
13487
+ if (!runtime)
13488
+ continue;
13489
+ for (const [id, entry] of Object.entries(runtime)) {
13490
+ if (!entry.filename || !entry.exportedName)
13491
+ continue;
13492
+ let exportedName = entry.exportedName;
13493
+ if (exportedName === "$$RSC_SERVER_ACTION_0") {
13494
+ exportedName = "anonymous_fn";
13495
+ }
13496
+ const route = {
13497
+ src: "/(.*)",
13498
+ has: [
13499
+ {
13500
+ type: "header",
13501
+ key: "next-action",
13502
+ value: id
13503
+ }
13504
+ ],
13505
+ transforms: [
13506
+ {
13507
+ type: "request.headers",
13508
+ op: "append",
13509
+ target: {
13510
+ key: "x-server-action-name"
13511
+ },
13512
+ args: `${entry.filename}#${exportedName}`
13513
+ }
13514
+ ]
13515
+ };
13516
+ routes.push(route);
13517
+ }
13518
+ }
13519
+ return routes;
13520
+ } catch (error) {
13521
+ return [];
13522
+ }
13523
+ }
13475
13524
 
13476
13525
  // src/create-serverless-config.ts
13477
13526
  function getCustomData(importName, target) {
@@ -13984,7 +14033,6 @@ async function serverBuild({
13984
14033
  const lambdas = {};
13985
14034
  const prerenders = {};
13986
14035
  const lambdaPageKeys = Object.keys(lambdaPages);
13987
- const internalPages = [...INTERNAL_PAGES];
13988
14036
  const pageBuildTraces = await (0, import_build_utils2.glob)("**/*.js.nft.json", pagesDir);
13989
14037
  const isEmptyAllowQueryForPrendered = import_semver3.default.gte(
13990
14038
  nextVersion,
@@ -14116,6 +14164,9 @@ async function serverBuild({
14116
14164
  const lstatResults = {};
14117
14165
  const nonLambdaSsgPages = /* @__PURE__ */ new Set();
14118
14166
  const static404Pages = new Set(static404Page ? [static404Page] : []);
14167
+ const internalPages = [...INTERNAL_PAGES].filter((page) => {
14168
+ return lambdaPages[page];
14169
+ });
14119
14170
  Object.keys(prerenderManifest.staticRoutes).forEach((route) => {
14120
14171
  const result = onPrerenderRouteInitial(
14121
14172
  prerenderManifest,
@@ -14472,7 +14523,7 @@ ${JSON.stringify(
14472
14523
  for (const page of mergedPageKeys) {
14473
14524
  const originalPagePath = getOriginalPagePath(page);
14474
14525
  const pageBuildTrace = getBuildTraceFile(originalPagePath);
14475
- let fileList;
14526
+ let fileList = [];
14476
14527
  let reasons;
14477
14528
  if (pageBuildTrace) {
14478
14529
  const { files } = JSON.parse(
@@ -14510,16 +14561,10 @@ ${JSON.stringify(
14510
14561
  });
14511
14562
  reasons = /* @__PURE__ */ new Map();
14512
14563
  } else {
14564
+ const lambdaPage = lambdaPages[page];
14513
14565
  fileList = Array.from(
14514
- parentFilesMap?.get(
14515
- import_path4.default.relative(baseDir, lambdaPages[page].fsPath)
14516
- ) || []
14566
+ parentFilesMap?.get(import_path4.default.relative(baseDir, lambdaPage.fsPath)) || []
14517
14567
  );
14518
- if (!fileList) {
14519
- throw new Error(
14520
- `Invariant: Failed to trace ${page}, missing fileList`
14521
- );
14522
- }
14523
14568
  reasons = traceResult?.reasons || /* @__PURE__ */ new Map();
14524
14569
  }
14525
14570
  const tracedFiles = Object.fromEntries(
@@ -15218,6 +15263,9 @@ ${JSON.stringify(
15218
15263
  const shouldHandleSegmentToRsc = Boolean(
15219
15264
  isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix
15220
15265
  );
15266
+ const serverActionMetaRoutes = await getServerActionMetaRoutes(
15267
+ import_path4.default.join(entryPath, outputDirectory)
15268
+ );
15221
15269
  return {
15222
15270
  wildcard: wildcardConfig,
15223
15271
  images: getImagesConfig(imagesManifest),
@@ -15374,6 +15422,7 @@ ${JSON.stringify(
15374
15422
  ] : [],
15375
15423
  ...headers,
15376
15424
  ...redirects,
15425
+ ...serverActionMetaRoutes,
15377
15426
  // middleware comes directly after redirects but before
15378
15427
  // beforeFiles rewrites as middleware is not a "file" route
15379
15428
  ...routesManifest?.skipMiddlewareUrlNormalize ? denormalizeNextDataRoute(true) : [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.11.2",
3
+ "version": "4.11.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",