@vercel/next 4.15.19 → 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
@@ -12657,7 +12657,9 @@ var onPrerenderRoute = (prerenderRouteArgs) => async (routeKey, {
12657
12657
  });
12658
12658
  }
12659
12659
  let dataFallbackFsRef = null;
12660
- if (!isFallback && !isBlocking && (!isNotFound || static404Page) && dataRoute && (!isAppClientParamParsingEnabled || prefetchDataRoute)) {
12660
+ if (!isFallback && !isBlocking && (!isNotFound || static404Page) && dataRoute && // When this is an App route, either isAppClientParamParsingEnabled is disabled
12661
+ // or there's a prefetchDataRoute
12662
+ (!isAppPathRoute || !isAppClientParamParsingEnabled || prefetchDataRoute)) {
12661
12663
  const basePath = isAppPathRoute && !isOmittedOrNotFound && appDir ? appDir : pagesDir;
12662
12664
  dataFallbackFsRef = new import_build_utils.FileFsRef({
12663
12665
  fsPath: import_path3.default.join(
@@ -14471,7 +14473,11 @@ async function serverBuild({
14471
14473
  nextVersion,
14472
14474
  CORRECT_MIDDLEWARE_ORDER_VERSION
14473
14475
  );
14474
- 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
+ );
14475
14481
  let hasStatic500 = !!staticPages[import_path5.default.posix.join(entryDirectory, "500")];
14476
14482
  if (lambdaPageKeys.length === 0) {
14477
14483
  throw new import_build_utils2.NowBuildError({
@@ -15087,52 +15093,58 @@ ${JSON.stringify(
15087
15093
  }
15088
15094
  const updatedManifestFiles = {};
15089
15095
  if (isCorrectManifests) {
15090
- for (const manifest of [
15096
+ for (const manifest of mayFilterManifests ? [
15091
15097
  "routes-manifest.json",
15092
15098
  "server/pages-manifest.json",
15093
15099
  ...appPathRoutesManifest ? ["server/app-paths-manifest.json"] : []
15094
- ]) {
15100
+ ] : ["routes-manifest.json"]) {
15095
15101
  const fsPath = import_path5.default.join(entryPath, outputDirectory, manifest);
15096
15102
  const relativePath = import_path5.default.relative(baseDir, fsPath);
15097
15103
  delete group.pseudoLayer[relativePath];
15098
15104
  const manifestData = await import_fs_extra5.default.readJSON(fsPath);
15099
- const normalizedPages = new Set(
15100
- group.pages.map((page) => {
15101
- page = `/${page.replace(/\.js$/, "")}`;
15102
- if (page === "/index")
15103
- page = "/";
15104
- return page;
15105
- })
15106
- );
15107
- switch (manifest) {
15108
- case "routes-manifest.json": {
15109
- const filterItem = (item) => normalizedPages.has(item.page);
15110
- manifestData.dynamicRoutes = manifestData.dynamicRoutes?.filter(filterItem);
15111
- manifestData.staticRoutes = manifestData.staticRoutes?.filter(filterItem);
15112
- break;
15113
- }
15114
- case "server/pages-manifest.json": {
15115
- for (const key of Object.keys(manifestData)) {
15116
- if (isDynamicRoute(key, nextVersion) && !normalizedPages.has(key)) {
15117
- 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
+ }
15118
15130
  }
15131
+ break;
15119
15132
  }
15120
- break;
15121
- }
15122
- case "server/app-paths-manifest.json": {
15123
- for (const key of Object.keys(manifestData)) {
15124
- const normalizedKey = appPathRoutesManifest?.[key] || key.replace(/(^|\/)(page|route)$/, "");
15125
- if (isDynamicRoute(normalizedKey, nextVersion) && !normalizedPages.has(normalizedKey)) {
15126
- 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
+ }
15127
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
+ });
15128
15147
  }
15129
- break;
15130
- }
15131
- default: {
15132
- throw new import_build_utils2.NowBuildError({
15133
- message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
15134
- code: "NEXT_MANIFEST_INVARIANT"
15135
- });
15136
15148
  }
15137
15149
  }
15138
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.19",
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",