@vercel/next 4.15.20 → 4.15.21

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.
@@ -23,17 +23,10 @@ __export(node_handler_exports, {
23
23
  module.exports = __toCommonJS(node_handler_exports);
24
24
  const getHandlerSource = (ctx) => `
25
25
  process.env.NODE_ENV = 'production';
26
- require('next/dist/server/node-environment');
27
- require('next/dist/server/node-polyfill-crypto');
28
-
29
- try {
30
- // this can fail to install if styled-jsx is not discoverable
31
- // but this is tolerable as the require-hook is handling edge cases
32
- require('next/dist/server/require-hook');
33
- } catch (_) {}
34
-
35
26
  process.chdir(__dirname);
36
27
 
28
+ require('next/setup-node-env')
29
+
37
30
  const _n_handler = (${ctx.isMiddleware ? () => {
38
31
  const path = require("path");
39
32
  const relativeDistDir = process.env.__PRIVATE_RELATIVE_DIST_DIR;
@@ -242,10 +235,18 @@ const getHandlerSource = (ctx) => `
242
235
  }
243
236
  }
244
237
  };
238
+ function fixMojibake(input) {
239
+ const bytes = new Uint8Array(input.length);
240
+ for (let i = 0; i < input.length; i++) {
241
+ bytes[i] = input.charCodeAt(i);
242
+ }
243
+ const decoder = new TextDecoder("utf-8");
244
+ return decoder.decode(bytes);
245
+ }
245
246
  return async function handler(req, res, internalMetadata) {
246
247
  try {
247
248
  const parsedUrl = new URL(req.url || "/", "http://n");
248
- let urlPathname = req.headers["x-matched-path"];
249
+ let urlPathname = typeof req.headers["x-matched-path"] === "string" ? fixMojibake(req.headers["x-matched-path"]) : void 0;
249
250
  if (typeof urlPathname !== "string") {
250
251
  console.log("no x-matched-path", { url: req.url });
251
252
  urlPathname = parsedUrl.pathname || "/";
package/dist/index.js CHANGED
@@ -14473,7 +14473,11 @@ async function serverBuild({
14473
14473
  nextVersion,
14474
14474
  CORRECT_MIDDLEWARE_ORDER_VERSION
14475
14475
  );
14476
- const isCorrectManifests = !experimentalAllowBundling && import_semver4.default.gte(nextVersion, CORRECTED_MANIFESTS_VERSION);
14476
+ const mayFilterManifests = !experimentalAllowBundling;
14477
+ const isCorrectManifests = import_semver4.default.gte(
14478
+ nextVersion,
14479
+ CORRECTED_MANIFESTS_VERSION
14480
+ );
14477
14481
  let hasStatic500 = !!staticPages[import_path5.default.posix.join(entryDirectory, "500")];
14478
14482
  if (lambdaPageKeys.length === 0) {
14479
14483
  throw new import_build_utils2.NowBuildError({
@@ -15089,52 +15093,58 @@ ${JSON.stringify(
15089
15093
  }
15090
15094
  const updatedManifestFiles = {};
15091
15095
  if (isCorrectManifests) {
15092
- for (const manifest of [
15096
+ for (const manifest of mayFilterManifests ? [
15093
15097
  "routes-manifest.json",
15094
15098
  "server/pages-manifest.json",
15095
15099
  ...appPathRoutesManifest ? ["server/app-paths-manifest.json"] : []
15096
- ]) {
15100
+ ] : ["routes-manifest.json"]) {
15097
15101
  const fsPath = import_path5.default.join(entryPath, outputDirectory, manifest);
15098
15102
  const relativePath = import_path5.default.relative(baseDir, fsPath);
15099
15103
  delete group.pseudoLayer[relativePath];
15100
15104
  const manifestData = await import_fs_extra5.default.readJSON(fsPath);
15101
- const normalizedPages = new Set(
15102
- group.pages.map((page) => {
15103
- page = `/${page.replace(/\.js$/, "")}`;
15104
- if (page === "/index")
15105
- page = "/";
15106
- return page;
15107
- })
15108
- );
15109
- switch (manifest) {
15110
- case "routes-manifest.json": {
15111
- const filterItem = (item) => normalizedPages.has(item.page);
15112
- manifestData.dynamicRoutes = manifestData.dynamicRoutes?.filter(filterItem);
15113
- manifestData.staticRoutes = manifestData.staticRoutes?.filter(filterItem);
15114
- break;
15115
- }
15116
- case "server/pages-manifest.json": {
15117
- for (const key of Object.keys(manifestData)) {
15118
- if (isDynamicRoute(key, nextVersion) && !normalizedPages.has(key)) {
15119
- delete manifestData[key];
15105
+ if (manifest === "routes-manifest.json") {
15106
+ manifestData.headers = [];
15107
+ delete manifestData.deploymentId;
15108
+ }
15109
+ if (mayFilterManifests) {
15110
+ const normalizedPages = new Set(
15111
+ group.pages.map((page) => {
15112
+ page = `/${page.replace(/\.js$/, "")}`;
15113
+ if (page === "/index")
15114
+ page = "/";
15115
+ return page;
15116
+ })
15117
+ );
15118
+ switch (manifest) {
15119
+ case "routes-manifest.json": {
15120
+ const filterItem = (item) => normalizedPages.has(item.page);
15121
+ manifestData.dynamicRoutes = manifestData.dynamicRoutes?.filter(filterItem);
15122
+ manifestData.staticRoutes = manifestData.staticRoutes?.filter(filterItem);
15123
+ break;
15124
+ }
15125
+ case "server/pages-manifest.json": {
15126
+ for (const key of Object.keys(manifestData)) {
15127
+ if (isDynamicRoute(key, nextVersion) && !normalizedPages.has(key)) {
15128
+ delete manifestData[key];
15129
+ }
15120
15130
  }
15131
+ break;
15121
15132
  }
15122
- break;
15123
- }
15124
- case "server/app-paths-manifest.json": {
15125
- for (const key of Object.keys(manifestData)) {
15126
- const normalizedKey = appPathRoutesManifest?.[key] || key.replace(/(^|\/)(page|route)$/, "");
15127
- if (isDynamicRoute(normalizedKey, nextVersion) && !normalizedPages.has(normalizedKey)) {
15128
- delete manifestData[key];
15133
+ case "server/app-paths-manifest.json": {
15134
+ for (const key of Object.keys(manifestData)) {
15135
+ const normalizedKey = appPathRoutesManifest?.[key] || key.replace(/(^|\/)(page|route)$/, "");
15136
+ if (isDynamicRoute(normalizedKey, nextVersion) && !normalizedPages.has(normalizedKey)) {
15137
+ delete manifestData[key];
15138
+ }
15129
15139
  }
15140
+ break;
15141
+ }
15142
+ default: {
15143
+ throw new import_build_utils2.NowBuildError({
15144
+ message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
15145
+ code: "NEXT_MANIFEST_INVARIANT"
15146
+ });
15130
15147
  }
15131
- break;
15132
- }
15133
- default: {
15134
- throw new import_build_utils2.NowBuildError({
15135
- message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
15136
- code: "NEXT_MANIFEST_INVARIANT"
15137
- });
15138
15148
  }
15139
15149
  }
15140
15150
  updatedManifestFiles[relativePath] = new import_build_utils2.FileBlob({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "4.15.20",
3
+ "version": "4.15.21",
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.2",
19
+ "@next-community/adapter-vercel": "0.0.1-beta.3",
20
20
  "@types/aws-lambda": "8.10.19",
21
21
  "@types/buffer-crc32": "0.2.0",
22
22
  "@types/bytes": "3.1.1",