@vercel/next 4.15.21 → 4.15.23

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.
@@ -9711,6 +9711,17 @@ async function handleStaticOutputs(outputs, {
9711
9711
  );
9712
9712
  }
9713
9713
  var vercelConfig = JSON.parse(process.env.NEXT_ADAPTER_VERCEL_CONFIG || "{}");
9714
+ async function writeDeterministicRoutesManifest(distDir) {
9715
+ const manifest = require(import_node_path.default.join(distDir, "routes-manifest.json"));
9716
+ manifest.headers = [];
9717
+ delete manifest.deploymentId;
9718
+ const outputManifestPath = import_node_path.default.join(
9719
+ distDir,
9720
+ "routes-manifest-deterministic.json"
9721
+ );
9722
+ await import_promises.default.writeFile(outputManifestPath, JSON.stringify(manifest));
9723
+ return outputManifestPath;
9724
+ }
9714
9725
  async function handleNodeOutputs(nodeOutputs, {
9715
9726
  config,
9716
9727
  distDir,
@@ -9738,6 +9749,14 @@ async function handleNodeOutputs(nodeOutputs, {
9738
9749
  break;
9739
9750
  }
9740
9751
  }
9752
+ const routesManifestDeterministicRelativePath = import_node_path.default.posix.relative(
9753
+ repoRoot,
9754
+ await writeDeterministicRoutesManifest(distDir)
9755
+ );
9756
+ const routesManifestRelativePath = import_node_path.default.posix.join(
9757
+ import_node_path.default.posix.relative(repoRoot, distDir),
9758
+ "routes-manifest.json"
9759
+ );
9741
9760
  await Promise.all(
9742
9761
  nodeOutputs.map(async (output) => {
9743
9762
  await fsSema.acquire();
@@ -9762,6 +9781,9 @@ async function handleNodeOutputs(nodeOutputs, {
9762
9781
  files[import_node_path.default.posix.relative(repoRoot, notFoundOutput.filePath)] = import_node_path.default.posix.relative(repoRoot, notFoundOutput.filePath);
9763
9782
  }
9764
9783
  }
9784
+ if (files[routesManifestRelativePath]) {
9785
+ files[routesManifestRelativePath] = routesManifestDeterministicRelativePath;
9786
+ }
9765
9787
  const handlerFilePath = import_node_path.default.join(
9766
9788
  functionDir,
9767
9789
  handlerRelativeDir,
Binary file
@@ -60,17 +60,16 @@ const getHandlerSource = (ctx) => `
60
60
  staticRoutes: staticRoutesRaw,
61
61
  i18n
62
62
  } = require("./" + path.posix.join(relativeDistDir, "routes-manifest.json"));
63
- const hydrateRoutesManifestItem = (item) => {
64
- return {
65
- ...item,
66
- namedRegex: new RegExp(item.namedRegex || item.regex)
67
- };
68
- };
69
63
  const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
70
64
  function escapeStringRegexp(str) {
71
65
  return str.replace(matchOperatorsRegex, "\\$&");
72
66
  }
73
- const dynamicRoutes = dynamicRoutesRaw.map(hydrateRoutesManifestItem);
67
+ const dynamicRoutes = dynamicRoutesRaw.map((item) => {
68
+ return {
69
+ ...item,
70
+ namedRegex: new RegExp(item.namedRegex || item.regex)
71
+ };
72
+ });
74
73
  const staticRoutes = staticRoutesRaw.map((route) => {
75
74
  return {
76
75
  ...route,
package/dist/index.js CHANGED
@@ -14260,6 +14260,7 @@ var CORRECT_MIDDLEWARE_ORDER_VERSION = "v12.1.7-canary.29";
14260
14260
  var NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = "v12.1.7-canary.33";
14261
14261
  var EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = "v12.2.0";
14262
14262
  var CORRECTED_MANIFESTS_VERSION = "v12.2.0";
14263
+ var DYNAMICALLY_RENDER_404_VERSION = "v16.2.0-canary.17";
14263
14264
  var PRELOAD_CHUNKS = {
14264
14265
  APP_ROUTER_PAGES: [
14265
14266
  ".next/server/webpack-runtime.js",
@@ -14478,6 +14479,10 @@ async function serverBuild({
14478
14479
  nextVersion,
14479
14480
  CORRECTED_MANIFESTS_VERSION
14480
14481
  );
14482
+ const shouldUse404Prerender = import_semver4.default.lt(
14483
+ nextVersion,
14484
+ DYNAMICALLY_RENDER_404_VERSION
14485
+ );
14481
14486
  let hasStatic500 = !!staticPages[import_path5.default.posix.join(entryDirectory, "500")];
14482
14487
  if (lambdaPageKeys.length === 0) {
14483
14488
  throw new import_build_utils2.NowBuildError({
@@ -14680,7 +14685,7 @@ async function serverBuild({
14680
14685
  mode: (await import_fs_extra5.default.lstat(nextServerFile)).mode,
14681
14686
  fsPath: nextServerFile
14682
14687
  });
14683
- if (static404Pages.size > 0) {
14688
+ if (shouldUse404Prerender && static404Pages.size > 0) {
14684
14689
  if (i18n) {
14685
14690
  for (const locale of i18n.locales) {
14686
14691
  const static404Page2 = import_path5.default.posix.join(entryDirectory, locale, "404");
@@ -15093,11 +15098,11 @@ ${JSON.stringify(
15093
15098
  }
15094
15099
  const updatedManifestFiles = {};
15095
15100
  if (isCorrectManifests) {
15096
- for (const manifest of mayFilterManifests ? [
15101
+ for (const manifest of [
15097
15102
  "routes-manifest.json",
15098
15103
  "server/pages-manifest.json",
15099
- ...appPathRoutesManifest ? ["server/app-paths-manifest.json"] : []
15100
- ] : ["routes-manifest.json"]) {
15104
+ ...mayFilterManifests && appPathRoutesManifest ? ["server/app-paths-manifest.json"] : []
15105
+ ]) {
15101
15106
  const fsPath = import_path5.default.join(entryPath, outputDirectory, manifest);
15102
15107
  const relativePath = import_path5.default.relative(baseDir, fsPath);
15103
15108
  delete group.pseudoLayer[relativePath];
@@ -15105,6 +15110,18 @@ ${JSON.stringify(
15105
15110
  if (manifest === "routes-manifest.json") {
15106
15111
  manifestData.headers = [];
15107
15112
  delete manifestData.deploymentId;
15113
+ } else if (manifest === "server/pages-manifest.json" && !shouldUse404Prerender) {
15114
+ if (manifestData["/404"] === "pages/404.html") {
15115
+ manifestData["/404"] = lambdaPages["404.js"] && !lambdaAppPaths["404.js"] ? "pages/404.js" : "pages/_error.js";
15116
+ }
15117
+ if (i18n) {
15118
+ for (const locale of i18n.locales) {
15119
+ const locale404Key = `/${locale}/404`;
15120
+ if (manifestData[locale404Key]?.endsWith("/404.html")) {
15121
+ manifestData[locale404Key] = lambdaPages["404.js"] && !lambdaAppPaths["404.js"] ? "pages/404.js" : "pages/_error.js";
15122
+ }
15123
+ }
15124
+ }
15108
15125
  }
15109
15126
  if (mayFilterManifests) {
15110
15127
  const normalizedPages = new Set(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.15.21",
3
+ "version": "4.15.23",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -16,7 +16,7 @@
16
16
  "@vercel/nft": "1.1.1"
17
17
  },
18
18
  "devDependencies": {
19
- "@next-community/adapter-vercel": "0.0.1-beta.3",
19
+ "@next-community/adapter-vercel": "0.0.1-beta.4",
20
20
  "@types/aws-lambda": "8.10.19",
21
21
  "@types/buffer-crc32": "0.2.0",
22
22
  "@types/bytes": "3.1.1",
@@ -53,7 +53,7 @@
53
53
  "test-listen": "1.1.0",
54
54
  "text-table": "0.2.0",
55
55
  "webpack-sources": "3.2.3",
56
- "@vercel/build-utils": "13.2.16",
56
+ "@vercel/build-utils": "13.3.1",
57
57
  "@vercel/routing-utils": "5.3.2"
58
58
  },
59
59
  "scripts": {