@vercel/next 4.15.20 → 4.15.22
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.
- package/dist/adapter/node-handler.js +11 -10
- package/dist/index.js +62 -35
- package/package.json +3 -3
|
@@ -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
|
@@ -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",
|
|
@@ -14473,7 +14474,15 @@ async function serverBuild({
|
|
|
14473
14474
|
nextVersion,
|
|
14474
14475
|
CORRECT_MIDDLEWARE_ORDER_VERSION
|
|
14475
14476
|
);
|
|
14476
|
-
const
|
|
14477
|
+
const mayFilterManifests = !experimentalAllowBundling;
|
|
14478
|
+
const isCorrectManifests = import_semver4.default.gte(
|
|
14479
|
+
nextVersion,
|
|
14480
|
+
CORRECTED_MANIFESTS_VERSION
|
|
14481
|
+
);
|
|
14482
|
+
const shouldUse404Prerender = import_semver4.default.lt(
|
|
14483
|
+
nextVersion,
|
|
14484
|
+
DYNAMICALLY_RENDER_404_VERSION
|
|
14485
|
+
);
|
|
14477
14486
|
let hasStatic500 = !!staticPages[import_path5.default.posix.join(entryDirectory, "500")];
|
|
14478
14487
|
if (lambdaPageKeys.length === 0) {
|
|
14479
14488
|
throw new import_build_utils2.NowBuildError({
|
|
@@ -14676,7 +14685,7 @@ async function serverBuild({
|
|
|
14676
14685
|
mode: (await import_fs_extra5.default.lstat(nextServerFile)).mode,
|
|
14677
14686
|
fsPath: nextServerFile
|
|
14678
14687
|
});
|
|
14679
|
-
if (static404Pages.size > 0) {
|
|
14688
|
+
if (shouldUse404Prerender && static404Pages.size > 0) {
|
|
14680
14689
|
if (i18n) {
|
|
14681
14690
|
for (const locale of i18n.locales) {
|
|
14682
14691
|
const static404Page2 = import_path5.default.posix.join(entryDirectory, locale, "404");
|
|
@@ -15089,52 +15098,70 @@ ${JSON.stringify(
|
|
|
15089
15098
|
}
|
|
15090
15099
|
const updatedManifestFiles = {};
|
|
15091
15100
|
if (isCorrectManifests) {
|
|
15092
|
-
for (const manifest of [
|
|
15101
|
+
for (const manifest of mayFilterManifests ? [
|
|
15093
15102
|
"routes-manifest.json",
|
|
15094
15103
|
"server/pages-manifest.json",
|
|
15095
15104
|
...appPathRoutesManifest ? ["server/app-paths-manifest.json"] : []
|
|
15096
|
-
]) {
|
|
15105
|
+
] : ["routes-manifest.json"]) {
|
|
15097
15106
|
const fsPath = import_path5.default.join(entryPath, outputDirectory, manifest);
|
|
15098
15107
|
const relativePath = import_path5.default.relative(baseDir, fsPath);
|
|
15099
15108
|
delete group.pseudoLayer[relativePath];
|
|
15100
15109
|
const manifestData = await import_fs_extra5.default.readJSON(fsPath);
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
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;
|
|
15110
|
+
if (manifest === "routes-manifest.json") {
|
|
15111
|
+
manifestData.headers = [];
|
|
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";
|
|
15115
15116
|
}
|
|
15116
|
-
|
|
15117
|
-
for (const
|
|
15118
|
-
|
|
15119
|
-
|
|
15117
|
+
if (i18n) {
|
|
15118
|
+
for (const locale of i18n.locales) {
|
|
15119
|
+
const locale404Key = `/${locale}/404`;
|
|
15120
|
+
if (manifestData[locale404Key] === `pages/${locale}/404.html`) {
|
|
15121
|
+
manifestData[locale404Key] = lambdaPages["404.js"] && !lambdaAppPaths["404.js"] ? `pages/404.js` : "pages/_error.js";
|
|
15120
15122
|
}
|
|
15121
15123
|
}
|
|
15122
|
-
break;
|
|
15123
15124
|
}
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15125
|
+
}
|
|
15126
|
+
if (mayFilterManifests) {
|
|
15127
|
+
const normalizedPages = new Set(
|
|
15128
|
+
group.pages.map((page) => {
|
|
15129
|
+
page = `/${page.replace(/\.js$/, "")}`;
|
|
15130
|
+
if (page === "/index")
|
|
15131
|
+
page = "/";
|
|
15132
|
+
return page;
|
|
15133
|
+
})
|
|
15134
|
+
);
|
|
15135
|
+
switch (manifest) {
|
|
15136
|
+
case "routes-manifest.json": {
|
|
15137
|
+
const filterItem = (item) => normalizedPages.has(item.page);
|
|
15138
|
+
manifestData.dynamicRoutes = manifestData.dynamicRoutes?.filter(filterItem);
|
|
15139
|
+
manifestData.staticRoutes = manifestData.staticRoutes?.filter(filterItem);
|
|
15140
|
+
break;
|
|
15141
|
+
}
|
|
15142
|
+
case "server/pages-manifest.json": {
|
|
15143
|
+
for (const key of Object.keys(manifestData)) {
|
|
15144
|
+
if (isDynamicRoute(key, nextVersion) && !normalizedPages.has(key)) {
|
|
15145
|
+
delete manifestData[key];
|
|
15146
|
+
}
|
|
15129
15147
|
}
|
|
15148
|
+
break;
|
|
15149
|
+
}
|
|
15150
|
+
case "server/app-paths-manifest.json": {
|
|
15151
|
+
for (const key of Object.keys(manifestData)) {
|
|
15152
|
+
const normalizedKey = appPathRoutesManifest?.[key] || key.replace(/(^|\/)(page|route)$/, "");
|
|
15153
|
+
if (isDynamicRoute(normalizedKey, nextVersion) && !normalizedPages.has(normalizedKey)) {
|
|
15154
|
+
delete manifestData[key];
|
|
15155
|
+
}
|
|
15156
|
+
}
|
|
15157
|
+
break;
|
|
15158
|
+
}
|
|
15159
|
+
default: {
|
|
15160
|
+
throw new import_build_utils2.NowBuildError({
|
|
15161
|
+
message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
|
|
15162
|
+
code: "NEXT_MANIFEST_INVARIANT"
|
|
15163
|
+
});
|
|
15130
15164
|
}
|
|
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
15165
|
}
|
|
15139
15166
|
}
|
|
15140
15167
|
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.
|
|
3
|
+
"version": "4.15.22",
|
|
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.
|
|
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",
|
|
@@ -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.
|
|
56
|
+
"@vercel/build-utils": "13.3.0",
|
|
57
57
|
"@vercel/routing-utils": "5.3.2"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|