@vercel/next 4.10.6 → 4.10.8
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/index.js +56 -148
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11124,42 +11124,12 @@ async function getRoutesManifest(entryPath, outputDirectory, nextVersion) {
|
|
|
11124
11124
|
}
|
|
11125
11125
|
return routesManifest;
|
|
11126
11126
|
}
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
case 4: {
|
|
11134
|
-
const routes = [];
|
|
11135
|
-
for (const {
|
|
11136
|
-
routeKeys,
|
|
11137
|
-
prefetchSegmentDataRoutes
|
|
11138
|
-
} of routesManifest.staticRoutes) {
|
|
11139
|
-
if (prefetchSegmentDataRoutes && prefetchSegmentDataRoutes.length > 0) {
|
|
11140
|
-
for (const prefetchSegmentDataRoute of prefetchSegmentDataRoutes) {
|
|
11141
|
-
routes.push({
|
|
11142
|
-
src: prefetchSegmentDataRoute.source,
|
|
11143
|
-
dest: getDestinationForSegmentRoute(
|
|
11144
|
-
false,
|
|
11145
|
-
entryDirectory,
|
|
11146
|
-
routeKeys,
|
|
11147
|
-
prefetchSegmentDataRoute
|
|
11148
|
-
),
|
|
11149
|
-
check: true
|
|
11150
|
-
});
|
|
11151
|
-
}
|
|
11152
|
-
}
|
|
11153
|
-
}
|
|
11154
|
-
return routes;
|
|
11155
|
-
}
|
|
11156
|
-
default: {
|
|
11157
|
-
throw new import_build_utils.NowBuildError({
|
|
11158
|
-
message: "This version of `@vercel/next` does not support the version of Next.js you are trying to deploy.\nPlease upgrade your `@vercel/next` builder and try again. Contact support if this continues to happen.",
|
|
11159
|
-
code: "NEXT_VERSION_UPGRADE"
|
|
11160
|
-
});
|
|
11161
|
-
}
|
|
11162
|
-
}
|
|
11127
|
+
function getDestinationForSegmentRoute(isDev, entryDirectory, routeKeys, prefetchSegmentDataRoute) {
|
|
11128
|
+
return `${!isDev ? import_path2.default.posix.join(
|
|
11129
|
+
"/",
|
|
11130
|
+
entryDirectory,
|
|
11131
|
+
prefetchSegmentDataRoute.destination
|
|
11132
|
+
) : prefetchSegmentDataRoute.destination}?${Object.entries(prefetchSegmentDataRoute.routeKeys ?? routeKeys ?? {}).map(([key, value]) => `${value}=$${key}`).join("&")}`;
|
|
11163
11133
|
}
|
|
11164
11134
|
async function getDynamicRoutes({
|
|
11165
11135
|
entryPath,
|
|
@@ -11248,28 +11218,25 @@ async function getDynamicRoutes({
|
|
|
11248
11218
|
});
|
|
11249
11219
|
}
|
|
11250
11220
|
}
|
|
11251
|
-
if (isAppPPREnabled) {
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11221
|
+
if (isAppPPREnabled || isAppClientSegmentCacheEnabled) {
|
|
11222
|
+
routes2.push({
|
|
11223
|
+
...route,
|
|
11224
|
+
src: route.src.replace(
|
|
11225
|
+
new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
|
|
11226
|
+
"(?<rscSuffix>\\.rsc|\\.prefetch\\.rsc|\\.segments/.+\\.segment\\.rsc)(?:/)?$"
|
|
11227
|
+
),
|
|
11228
|
+
dest: route.dest?.replace(/($|\?)/, "$rscSuffix$1")
|
|
11229
|
+
});
|
|
11230
|
+
} else {
|
|
11256
11231
|
routes2.push({
|
|
11257
11232
|
...route,
|
|
11258
11233
|
src: route.src.replace(
|
|
11259
11234
|
new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
|
|
11260
|
-
"(?:\\.
|
|
11235
|
+
"(?:\\.rsc)(?:/)?$"
|
|
11261
11236
|
),
|
|
11262
|
-
dest
|
|
11237
|
+
dest: route.dest?.replace(/($|\?)/, ".rsc$1")
|
|
11263
11238
|
});
|
|
11264
11239
|
}
|
|
11265
|
-
routes2.push({
|
|
11266
|
-
...route,
|
|
11267
|
-
src: route.src.replace(
|
|
11268
|
-
new RegExp((0, import_escape_string_regexp.default)("(?:/)?$")),
|
|
11269
|
-
"(?:\\.rsc)(?:/)?$"
|
|
11270
|
-
),
|
|
11271
|
-
dest: route.dest?.replace(/($|\?)/, ".rsc$1")
|
|
11272
|
-
});
|
|
11273
11240
|
routes2.push(route);
|
|
11274
11241
|
}
|
|
11275
11242
|
return routes2;
|
|
@@ -11333,13 +11300,6 @@ async function getDynamicRoutes({
|
|
|
11333
11300
|
});
|
|
11334
11301
|
return routes;
|
|
11335
11302
|
}
|
|
11336
|
-
function getDestinationForSegmentRoute(isDev, entryDirectory, routeKeys, prefetchSegmentDataRoute) {
|
|
11337
|
-
return `${!isDev ? import_path2.default.posix.join(
|
|
11338
|
-
"/",
|
|
11339
|
-
entryDirectory,
|
|
11340
|
-
prefetchSegmentDataRoute.destination
|
|
11341
|
-
) : prefetchSegmentDataRoute.destination}?${Object.entries(prefetchSegmentDataRoute.routeKeys ?? routeKeys ?? {}).map(([key, value]) => `${value}=$${key}`).join("&")}`;
|
|
11342
|
-
}
|
|
11343
11303
|
function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes, inversedAppPathRoutesManifest) {
|
|
11344
11304
|
const finalDynamicRoutes = [];
|
|
11345
11305
|
const nonLocalePrefixedRoutes = [];
|
|
@@ -13000,19 +12960,17 @@ async function getNodeMiddleware({
|
|
|
13000
12960
|
)
|
|
13001
12961
|
)).filter((entry) => !!entry)
|
|
13002
12962
|
);
|
|
12963
|
+
const absoluteOutputDirectory = import_path2.default.posix.join(entryPath, outputDirectory);
|
|
13003
12964
|
const launcherData = (await import_fs_extra3.default.readFile(import_path2.default.join(__dirname, "middleware-launcher.js"), "utf8")).replace(
|
|
13004
12965
|
/(?:var|const) conf = __NEXT_CONFIG__/,
|
|
13005
12966
|
`const conf = ${JSON.stringify({
|
|
13006
12967
|
...requiredServerFilesManifest.config,
|
|
13007
|
-
distDir: import_path2.default.relative(
|
|
13008
|
-
projectDir,
|
|
13009
|
-
import_path2.default.join(entryPath, outputDirectory)
|
|
13010
|
-
)
|
|
12968
|
+
distDir: import_path2.default.relative(projectDir, absoluteOutputDirectory)
|
|
13011
12969
|
})}`
|
|
13012
12970
|
).replace(
|
|
13013
12971
|
"__NEXT_MIDDLEWARE_PATH__",
|
|
13014
12972
|
"./" + import_path2.default.posix.join(
|
|
13015
|
-
import_path2.default.posix.relative(projectDir,
|
|
12973
|
+
import_path2.default.posix.relative(projectDir, absoluteOutputDirectory),
|
|
13016
12974
|
`server/middleware.js`
|
|
13017
12975
|
)
|
|
13018
12976
|
);
|
|
@@ -14056,64 +14014,15 @@ async function serverBuild({
|
|
|
14056
14014
|
continue;
|
|
14057
14015
|
if (protocol || !pathname && !query)
|
|
14058
14016
|
continue;
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
!m.value || m.value === "1"
|
|
14068
|
-
)
|
|
14069
|
-
)) {
|
|
14070
|
-
continue;
|
|
14071
|
-
}
|
|
14072
|
-
const has = "has" in rewrite && rewrite.has ? (
|
|
14073
|
-
// As we mutate the array below, we need to clone it to avoid
|
|
14074
|
-
// mutating the original
|
|
14075
|
-
[...rewrite.has]
|
|
14076
|
-
) : [];
|
|
14077
|
-
found = has.filter(
|
|
14078
|
-
(h) => h.type === "header" && h.key.toLowerCase() === rscHeader
|
|
14079
|
-
);
|
|
14080
|
-
if (found.some(
|
|
14081
|
-
(h) => (
|
|
14082
|
-
// These are rules that have a value set to anything other than
|
|
14083
|
-
// '1'.
|
|
14084
|
-
h.value && h.value !== "1"
|
|
14085
|
-
)
|
|
14086
|
-
)) {
|
|
14087
|
-
continue;
|
|
14088
|
-
}
|
|
14089
|
-
for (const h of found) {
|
|
14090
|
-
has.splice(has.indexOf(h), 1);
|
|
14091
|
-
}
|
|
14092
|
-
has.push({ type: "header", key: rscHeader, value: "1" });
|
|
14093
|
-
const headers2 = "headers" in rewrite && rewrite.headers ? (
|
|
14094
|
-
// Clone the existing headers to avoid mutating the original
|
|
14095
|
-
// object.
|
|
14096
|
-
{ ...rewrite.headers }
|
|
14097
|
-
) : {};
|
|
14098
|
-
const updated = {
|
|
14099
|
-
...rewrite,
|
|
14100
|
-
// We don't want to perform the actual rewrite here, instead we want
|
|
14101
|
-
// to just add the headers associated with the rewrite.
|
|
14102
|
-
dest: void 0,
|
|
14103
|
-
// We don't want to check here, so omit the check property but we do
|
|
14104
|
-
// want to maintain the order of the rewrites, so add the continue
|
|
14105
|
-
// property.
|
|
14106
|
-
check: void 0,
|
|
14107
|
-
continue: true,
|
|
14108
|
-
has,
|
|
14109
|
-
headers: headers2
|
|
14017
|
+
rewrite.headers = {
|
|
14018
|
+
...rewrite.headers,
|
|
14019
|
+
...pathname ? {
|
|
14020
|
+
[rewriteHeaders.pathHeader]: pathname
|
|
14021
|
+
} : {},
|
|
14022
|
+
...query ? {
|
|
14023
|
+
[rewriteHeaders.queryHeader]: query
|
|
14024
|
+
} : {}
|
|
14110
14025
|
};
|
|
14111
|
-
if (pathname)
|
|
14112
|
-
headers2[rewriteHeaders.pathHeader] = pathname;
|
|
14113
|
-
if (query)
|
|
14114
|
-
headers2[rewriteHeaders.queryHeader] = query;
|
|
14115
|
-
rewrites.splice(i, 0, updated);
|
|
14116
|
-
i++;
|
|
14117
14026
|
}
|
|
14118
14027
|
};
|
|
14119
14028
|
modifyRewrites(beforeFilesRewrites);
|
|
@@ -15068,10 +14977,6 @@ ${JSON.stringify(
|
|
|
15068
14977
|
)];
|
|
15069
14978
|
});
|
|
15070
14979
|
const isNextDataServerResolving = (middleware.staticRoutes.length > 0 || nodeMiddleware) && import_semver3.default.gte(nextVersion, NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION);
|
|
15071
|
-
const staticSegmentRoutes = isAppClientSegmentCacheEnabled ? await getStaticSegmentRoutes({
|
|
15072
|
-
entryDirectory,
|
|
15073
|
-
routesManifest
|
|
15074
|
-
}) : [];
|
|
15075
14980
|
const dynamicRoutes = await getDynamicRoutes({
|
|
15076
14981
|
entryPath,
|
|
15077
14982
|
entryDirectory,
|
|
@@ -15109,10 +15014,14 @@ ${JSON.stringify(
|
|
|
15109
15014
|
const pagesEntries = Object.keys(pagesData);
|
|
15110
15015
|
for (const page of pagesEntries) {
|
|
15111
15016
|
const pathName = page.startsWith("/") ? page.slice(1) : page;
|
|
15112
|
-
|
|
15017
|
+
const dummyBlob = new import_build_utils2.FileBlob({
|
|
15113
15018
|
data: "{}",
|
|
15114
15019
|
contentType: "application/json"
|
|
15115
15020
|
});
|
|
15021
|
+
pagesPlaceholderRscEntries[`${pathName}.rsc`] = dummyBlob;
|
|
15022
|
+
if (isAppClientSegmentCacheEnabled) {
|
|
15023
|
+
pagesPlaceholderRscEntries[`${pathName}.segments/_tree.segment.rsc`] = dummyBlob;
|
|
15024
|
+
}
|
|
15116
15025
|
}
|
|
15117
15026
|
}
|
|
15118
15027
|
const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await getStaticFiles(entryPath, entryDirectory, outputDirectory);
|
|
@@ -15515,7 +15424,9 @@ ${JSON.stringify(
|
|
|
15515
15424
|
override: true
|
|
15516
15425
|
}
|
|
15517
15426
|
] : [],
|
|
15518
|
-
...rscPrefetchHeader && isAppPPREnabled
|
|
15427
|
+
...rscPrefetchHeader && isAppPPREnabled && // when client segment cache is enabled we do not need
|
|
15428
|
+
// the .prefetch.rsc routing
|
|
15429
|
+
!isAppClientSegmentCacheEnabled ? [
|
|
15519
15430
|
{
|
|
15520
15431
|
src: `^${import_path4.default.posix.join("/", entryDirectory, "/")}$`,
|
|
15521
15432
|
has: [
|
|
@@ -15727,6 +15638,23 @@ ${JSON.stringify(
|
|
|
15727
15638
|
check: true
|
|
15728
15639
|
}
|
|
15729
15640
|
] : [],
|
|
15641
|
+
// If it didn't match any of the static routes or dynamic ones, then we
|
|
15642
|
+
// should fallback to the regular RSC request.
|
|
15643
|
+
...isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix ? [
|
|
15644
|
+
{
|
|
15645
|
+
src: import_path4.default.posix.join(
|
|
15646
|
+
"/",
|
|
15647
|
+
entryDirectory,
|
|
15648
|
+
`/(?<path>.+)${(0, import_escape_string_regexp2.default)(prefetchSegmentDirSuffix)}/.+${(0, import_escape_string_regexp2.default)(prefetchSegmentSuffix)}$`
|
|
15649
|
+
),
|
|
15650
|
+
dest: import_path4.default.posix.join(
|
|
15651
|
+
"/",
|
|
15652
|
+
entryDirectory,
|
|
15653
|
+
isAppPPREnabled ? "/$path.prefetch.rsc" : "/$path.rsc"
|
|
15654
|
+
),
|
|
15655
|
+
check: true
|
|
15656
|
+
}
|
|
15657
|
+
] : [],
|
|
15730
15658
|
// routes that are called after each rewrite or after routes
|
|
15731
15659
|
// if there no rewrites
|
|
15732
15660
|
{ handle: "rewrite" },
|
|
@@ -15798,7 +15726,6 @@ ${JSON.stringify(
|
|
|
15798
15726
|
status: 404
|
|
15799
15727
|
}
|
|
15800
15728
|
] : [],
|
|
15801
|
-
...staticSegmentRoutes,
|
|
15802
15729
|
// Dynamic routes (must come after dataRoutes as dataRoutes are more
|
|
15803
15730
|
// specific)
|
|
15804
15731
|
...dynamicRoutes,
|
|
@@ -15830,23 +15757,6 @@ ${JSON.stringify(
|
|
|
15830
15757
|
dest: "__next_data_catchall"
|
|
15831
15758
|
}
|
|
15832
15759
|
] : [],
|
|
15833
|
-
// If it didn't match any of the static routes or dynamic ones, then we
|
|
15834
|
-
// should fallback to the regular RSC request.
|
|
15835
|
-
...isAppClientSegmentCacheEnabled && rscPrefetchHeader && prefetchSegmentHeader && prefetchSegmentDirSuffix && prefetchSegmentSuffix ? [
|
|
15836
|
-
{
|
|
15837
|
-
src: import_path4.default.posix.join(
|
|
15838
|
-
"/",
|
|
15839
|
-
entryDirectory,
|
|
15840
|
-
`/(?<path>.+)${(0, import_escape_string_regexp2.default)(prefetchSegmentDirSuffix)}/.+${(0, import_escape_string_regexp2.default)(prefetchSegmentSuffix)}$`
|
|
15841
|
-
),
|
|
15842
|
-
dest: import_path4.default.posix.join(
|
|
15843
|
-
"/",
|
|
15844
|
-
entryDirectory,
|
|
15845
|
-
isAppPPREnabled ? "/$path.prefetch.rsc" : "/$path.rsc"
|
|
15846
|
-
),
|
|
15847
|
-
check: true
|
|
15848
|
-
}
|
|
15849
|
-
] : [],
|
|
15850
15760
|
// routes to call after a file has been matched
|
|
15851
15761
|
{ handle: "hit" },
|
|
15852
15762
|
// Before we handle static files we need to set proper caching headers
|
|
@@ -17390,8 +17300,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
|
17390
17300
|
canUsePreviewMode,
|
|
17391
17301
|
bypassToken: prerenderManifest.bypassToken || "",
|
|
17392
17302
|
isServerMode,
|
|
17393
|
-
isAppPPREnabled: false
|
|
17394
|
-
isAppClientSegmentCacheEnabled: false
|
|
17303
|
+
isAppPPREnabled: false
|
|
17395
17304
|
}).then(
|
|
17396
17305
|
(arr) => localizeDynamicRoutes(
|
|
17397
17306
|
arr,
|
|
@@ -17417,8 +17326,7 @@ More info: http://err.sh/vercel/vercel/next-functions-config-optimized-lambdas`
|
|
|
17417
17326
|
canUsePreviewMode,
|
|
17418
17327
|
bypassToken: prerenderManifest.bypassToken || "",
|
|
17419
17328
|
isServerMode,
|
|
17420
|
-
isAppPPREnabled: false
|
|
17421
|
-
isAppClientSegmentCacheEnabled: false
|
|
17329
|
+
isAppPPREnabled: false
|
|
17422
17330
|
}).then(
|
|
17423
17331
|
(arr) => arr.map((route) => {
|
|
17424
17332
|
route.src = route.src.replace("^", `^${dynamicPrefix}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/next",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/semver": "6.0.0",
|
|
31
31
|
"@types/text-table": "0.2.1",
|
|
32
32
|
"@types/webpack-sources": "3.2.0",
|
|
33
|
-
"@vercel/build-utils": "
|
|
33
|
+
"@vercel/build-utils": "11.0.0",
|
|
34
34
|
"@vercel/routing-utils": "5.1.1",
|
|
35
35
|
"async-sema": "3.0.1",
|
|
36
36
|
"buffer-crc32": "0.2.13",
|