@vercel/next 3.1.27 → 3.1.29
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 +69 -24
- package/dist/server-build.js +32 -0
- package/dist/utils.js +30 -23
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -43356,7 +43356,11 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
43356
43356
|
else {
|
43357
43357
|
(0, build_utils_1.debug)('Preparing serverless function files...');
|
43358
43358
|
const pagesDir = path_1.default.join(entryPath, outputDirectory, isServerMode ? 'server' : 'serverless', 'pages');
|
43359
|
+
let appDir = null;
|
43359
43360
|
const appPathRoutesManifest = await (0, fs_extra_1.readJSON)(path_1.default.join(entryPath, outputDirectory, 'app-path-routes-manifest.json')).catch(() => null);
|
43361
|
+
if (appPathRoutesManifest) {
|
43362
|
+
appDir = path_1.default.join(pagesDir, '../app');
|
43363
|
+
}
|
43360
43364
|
const { pages, appPaths: lambdaAppPaths } = await getServerlessPages({
|
43361
43365
|
pagesDir,
|
43362
43366
|
entryPath,
|
@@ -44002,9 +44006,10 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
44002
44006
|
console.timeEnd(allLambdasLabel);
|
44003
44007
|
}
|
44004
44008
|
const prerenderRoute = (0, utils_1.onPrerenderRoute)({
|
44009
|
+
appDir,
|
44010
|
+
pagesDir,
|
44005
44011
|
hasPages404,
|
44006
44012
|
static404Page,
|
44007
|
-
pagesDir,
|
44008
44013
|
pageLambdaMap,
|
44009
44014
|
lambdas,
|
44010
44015
|
isServerMode,
|
@@ -44012,6 +44017,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
44012
44017
|
entryDirectory,
|
44013
44018
|
routesManifest,
|
44014
44019
|
prerenderManifest,
|
44020
|
+
appPathRoutesManifest,
|
44015
44021
|
isSharedLambdas,
|
44016
44022
|
canUsePreviewMode,
|
44017
44023
|
});
|
@@ -45338,6 +45344,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45338
45344
|
console.timeEnd(lambdaCreationLabel);
|
45339
45345
|
}
|
45340
45346
|
const prerenderRoute = (0, utils_1.onPrerenderRoute)({
|
45347
|
+
appDir,
|
45341
45348
|
pagesDir,
|
45342
45349
|
pageLambdaMap: {},
|
45343
45350
|
lambdas,
|
@@ -45345,6 +45352,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45345
45352
|
entryDirectory,
|
45346
45353
|
routesManifest,
|
45347
45354
|
prerenderManifest,
|
45355
|
+
appPathRoutesManifest,
|
45348
45356
|
isServerMode: true,
|
45349
45357
|
isSharedLambdas: false,
|
45350
45358
|
canUsePreviewMode,
|
@@ -45490,6 +45498,21 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45490
45498
|
fsPath: catchallFsPath,
|
45491
45499
|
});
|
45492
45500
|
}
|
45501
|
+
if (appPathRoutesManifest) {
|
45502
|
+
// create .rsc variant for app lambdas and edge functions
|
45503
|
+
// to match prerenders so we can route the same when the
|
45504
|
+
// __flight__ header is present
|
45505
|
+
const edgeFunctions = middleware.edgeFunctions;
|
45506
|
+
for (let route of Object.values(appPathRoutesManifest)) {
|
45507
|
+
route = path_1.default.posix.join('./', route === '/' ? '/index' : route);
|
45508
|
+
if (lambdas[route]) {
|
45509
|
+
lambdas[`${route}.rsc`] = lambdas[route];
|
45510
|
+
}
|
45511
|
+
else if (edgeFunctions[route]) {
|
45512
|
+
edgeFunctions[`${route}.rsc`] = edgeFunctions[route];
|
45513
|
+
}
|
45514
|
+
}
|
45515
|
+
}
|
45493
45516
|
return {
|
45494
45517
|
wildcard: wildcardConfig,
|
45495
45518
|
images: imagesManifest?.images?.loader === 'default'
|
@@ -45670,6 +45693,21 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45670
45693
|
// handle: 'filesystem' we maintain this for older versions
|
45671
45694
|
// to prevent a local/deploy mismatch
|
45672
45695
|
...(!isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
|
45696
|
+
...(appDir
|
45697
|
+
? [
|
45698
|
+
{
|
45699
|
+
src: `^${path_1.default.posix.join('/', entryDirectory, '/(.*)$')}`,
|
45700
|
+
has: [
|
45701
|
+
{
|
45702
|
+
type: 'header',
|
45703
|
+
key: '__flight__',
|
45704
|
+
},
|
45705
|
+
],
|
45706
|
+
dest: path_1.default.posix.join('/', entryDirectory, '/$1.rsc'),
|
45707
|
+
check: true,
|
45708
|
+
},
|
45709
|
+
]
|
45710
|
+
: []),
|
45673
45711
|
// Next.js page lambdas, `static/` folder, reserved assets, and `public/`
|
45674
45712
|
// folder
|
45675
45713
|
{ handle: 'filesystem' },
|
@@ -47028,7 +47066,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
|
|
47028
47066
|
exports.onPrerenderRouteInitial = onPrerenderRouteInitial;
|
47029
47067
|
let prerenderGroup = 1;
|
47030
47068
|
const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFallback, isOmitted, locale, }) => {
|
47031
|
-
const { pagesDir, hasPages404, static404Page, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
47069
|
+
const { appDir, pagesDir, hasPages404, static404Page, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
47032
47070
|
if (isBlocking && isFallback) {
|
47033
47071
|
throw new build_utils_1.NowBuildError({
|
47034
47072
|
code: 'NEXT_ISBLOCKING_ISFALLBACK',
|
@@ -47064,28 +47102,6 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
47064
47102
|
routeFileNoExt, routesManifest, locale);
|
47065
47103
|
}
|
47066
47104
|
const isNotFound = prerenderManifest.notFoundRoutes.includes(routeKey);
|
47067
|
-
const htmlFsRef = isBlocking || (isNotFound && !static404Page)
|
47068
|
-
? // Blocking pages do not have an HTML fallback
|
47069
|
-
null
|
47070
|
-
: new build_utils_1.FileFsRef({
|
47071
|
-
fsPath: path_1.default.join(pagesDir, isFallback
|
47072
|
-
? // Fallback pages have a special file.
|
47073
|
-
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
47074
|
-
: // Otherwise, the route itself should exist as a static HTML
|
47075
|
-
// file.
|
47076
|
-
`${isOmitted || isNotFound
|
47077
|
-
? addLocaleOrDefault('/404', routesManifest, locale)
|
47078
|
-
: routeFileNoExt}.html`),
|
47079
|
-
});
|
47080
|
-
const jsonFsRef =
|
47081
|
-
// JSON data does not exist for fallback or blocking pages
|
47082
|
-
isFallback || isBlocking || (isNotFound && !static404Page)
|
47083
|
-
? null
|
47084
|
-
: new build_utils_1.FileFsRef({
|
47085
|
-
fsPath: path_1.default.join(pagesDir, `${isOmitted || isNotFound
|
47086
|
-
? addLocaleOrDefault('/404.html', routesManifest, locale)
|
47087
|
-
: routeFileNoExt + '.json'}`),
|
47088
|
-
});
|
47089
47105
|
let initialRevalidate;
|
47090
47106
|
let srcRoute;
|
47091
47107
|
let dataRoute;
|
@@ -47114,6 +47130,35 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
47114
47130
|
const pr = prerenderManifest.staticRoutes[routeKey];
|
47115
47131
|
({ initialRevalidate, srcRoute, dataRoute } = pr);
|
47116
47132
|
}
|
47133
|
+
let isAppPathRoute = false;
|
47134
|
+
// TODO: leverage manifest to determine app paths more accurately
|
47135
|
+
if (appDir && srcRoute && dataRoute.endsWith('.rsc')) {
|
47136
|
+
isAppPathRoute = true;
|
47137
|
+
}
|
47138
|
+
const htmlFsRef = isBlocking || (isNotFound && !static404Page)
|
47139
|
+
? // Blocking pages do not have an HTML fallback
|
47140
|
+
null
|
47141
|
+
: new build_utils_1.FileFsRef({
|
47142
|
+
fsPath: path_1.default.join(isAppPathRoute && appDir ? appDir : pagesDir, isFallback
|
47143
|
+
? // Fallback pages have a special file.
|
47144
|
+
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
47145
|
+
: // Otherwise, the route itself should exist as a static HTML
|
47146
|
+
// file.
|
47147
|
+
`${isOmitted || isNotFound
|
47148
|
+
? addLocaleOrDefault('/404', routesManifest, locale)
|
47149
|
+
: routeFileNoExt}.html`),
|
47150
|
+
});
|
47151
|
+
const jsonFsRef =
|
47152
|
+
// JSON data does not exist for fallback or blocking pages
|
47153
|
+
isFallback || isBlocking || (isNotFound && !static404Page)
|
47154
|
+
? null
|
47155
|
+
: new build_utils_1.FileFsRef({
|
47156
|
+
fsPath: path_1.default.join(isAppPathRoute && appDir ? appDir : pagesDir, `${isOmitted || isNotFound
|
47157
|
+
? addLocaleOrDefault('/404.html', routesManifest, locale)
|
47158
|
+
: isAppPathRoute
|
47159
|
+
? dataRoute
|
47160
|
+
: routeFileNoExt + '.json'}`),
|
47161
|
+
});
|
47117
47162
|
const outputPathPage = normalizeIndexOutput(path_1.default.posix.join(entryDirectory, routeFileNoExt), isServerMode);
|
47118
47163
|
const outputPathPageOrig = path_1.default.posix.join(entryDirectory, origRouteFileNoExt);
|
47119
47164
|
let lambda;
|
package/dist/server-build.js
CHANGED
@@ -495,6 +495,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
495
495
|
console.timeEnd(lambdaCreationLabel);
|
496
496
|
}
|
497
497
|
const prerenderRoute = (0, utils_1.onPrerenderRoute)({
|
498
|
+
appDir,
|
498
499
|
pagesDir,
|
499
500
|
pageLambdaMap: {},
|
500
501
|
lambdas,
|
@@ -502,6 +503,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
502
503
|
entryDirectory,
|
503
504
|
routesManifest,
|
504
505
|
prerenderManifest,
|
506
|
+
appPathRoutesManifest,
|
505
507
|
isServerMode: true,
|
506
508
|
isSharedLambdas: false,
|
507
509
|
canUsePreviewMode,
|
@@ -647,6 +649,21 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
647
649
|
fsPath: catchallFsPath,
|
648
650
|
});
|
649
651
|
}
|
652
|
+
if (appPathRoutesManifest) {
|
653
|
+
// create .rsc variant for app lambdas and edge functions
|
654
|
+
// to match prerenders so we can route the same when the
|
655
|
+
// __flight__ header is present
|
656
|
+
const edgeFunctions = middleware.edgeFunctions;
|
657
|
+
for (let route of Object.values(appPathRoutesManifest)) {
|
658
|
+
route = path_1.default.posix.join('./', route === '/' ? '/index' : route);
|
659
|
+
if (lambdas[route]) {
|
660
|
+
lambdas[`${route}.rsc`] = lambdas[route];
|
661
|
+
}
|
662
|
+
else if (edgeFunctions[route]) {
|
663
|
+
edgeFunctions[`${route}.rsc`] = edgeFunctions[route];
|
664
|
+
}
|
665
|
+
}
|
666
|
+
}
|
650
667
|
return {
|
651
668
|
wildcard: wildcardConfig,
|
652
669
|
images: imagesManifest?.images?.loader === 'default'
|
@@ -827,6 +844,21 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
827
844
|
// handle: 'filesystem' we maintain this for older versions
|
828
845
|
// to prevent a local/deploy mismatch
|
829
846
|
...(!isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
|
847
|
+
...(appDir
|
848
|
+
? [
|
849
|
+
{
|
850
|
+
src: `^${path_1.default.posix.join('/', entryDirectory, '/(.*)$')}`,
|
851
|
+
has: [
|
852
|
+
{
|
853
|
+
type: 'header',
|
854
|
+
key: '__flight__',
|
855
|
+
},
|
856
|
+
],
|
857
|
+
dest: path_1.default.posix.join('/', entryDirectory, '/$1.rsc'),
|
858
|
+
check: true,
|
859
|
+
},
|
860
|
+
]
|
861
|
+
: []),
|
830
862
|
// Next.js page lambdas, `static/` folder, reserved assets, and `public/`
|
831
863
|
// folder
|
832
864
|
{ handle: 'filesystem' },
|
package/dist/utils.js
CHANGED
@@ -1027,7 +1027,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
|
|
1027
1027
|
exports.onPrerenderRouteInitial = onPrerenderRouteInitial;
|
1028
1028
|
let prerenderGroup = 1;
|
1029
1029
|
const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFallback, isOmitted, locale, }) => {
|
1030
|
-
const { pagesDir, hasPages404, static404Page, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
1030
|
+
const { appDir, pagesDir, hasPages404, static404Page, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
1031
1031
|
if (isBlocking && isFallback) {
|
1032
1032
|
throw new build_utils_1.NowBuildError({
|
1033
1033
|
code: 'NEXT_ISBLOCKING_ISFALLBACK',
|
@@ -1063,28 +1063,6 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1063
1063
|
routeFileNoExt, routesManifest, locale);
|
1064
1064
|
}
|
1065
1065
|
const isNotFound = prerenderManifest.notFoundRoutes.includes(routeKey);
|
1066
|
-
const htmlFsRef = isBlocking || (isNotFound && !static404Page)
|
1067
|
-
? // Blocking pages do not have an HTML fallback
|
1068
|
-
null
|
1069
|
-
: new build_utils_1.FileFsRef({
|
1070
|
-
fsPath: path_1.default.join(pagesDir, isFallback
|
1071
|
-
? // Fallback pages have a special file.
|
1072
|
-
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
1073
|
-
: // Otherwise, the route itself should exist as a static HTML
|
1074
|
-
// file.
|
1075
|
-
`${isOmitted || isNotFound
|
1076
|
-
? addLocaleOrDefault('/404', routesManifest, locale)
|
1077
|
-
: routeFileNoExt}.html`),
|
1078
|
-
});
|
1079
|
-
const jsonFsRef =
|
1080
|
-
// JSON data does not exist for fallback or blocking pages
|
1081
|
-
isFallback || isBlocking || (isNotFound && !static404Page)
|
1082
|
-
? null
|
1083
|
-
: new build_utils_1.FileFsRef({
|
1084
|
-
fsPath: path_1.default.join(pagesDir, `${isOmitted || isNotFound
|
1085
|
-
? addLocaleOrDefault('/404.html', routesManifest, locale)
|
1086
|
-
: routeFileNoExt + '.json'}`),
|
1087
|
-
});
|
1088
1066
|
let initialRevalidate;
|
1089
1067
|
let srcRoute;
|
1090
1068
|
let dataRoute;
|
@@ -1113,6 +1091,35 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1113
1091
|
const pr = prerenderManifest.staticRoutes[routeKey];
|
1114
1092
|
({ initialRevalidate, srcRoute, dataRoute } = pr);
|
1115
1093
|
}
|
1094
|
+
let isAppPathRoute = false;
|
1095
|
+
// TODO: leverage manifest to determine app paths more accurately
|
1096
|
+
if (appDir && srcRoute && dataRoute.endsWith('.rsc')) {
|
1097
|
+
isAppPathRoute = true;
|
1098
|
+
}
|
1099
|
+
const htmlFsRef = isBlocking || (isNotFound && !static404Page)
|
1100
|
+
? // Blocking pages do not have an HTML fallback
|
1101
|
+
null
|
1102
|
+
: new build_utils_1.FileFsRef({
|
1103
|
+
fsPath: path_1.default.join(isAppPathRoute && appDir ? appDir : pagesDir, isFallback
|
1104
|
+
? // Fallback pages have a special file.
|
1105
|
+
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
1106
|
+
: // Otherwise, the route itself should exist as a static HTML
|
1107
|
+
// file.
|
1108
|
+
`${isOmitted || isNotFound
|
1109
|
+
? addLocaleOrDefault('/404', routesManifest, locale)
|
1110
|
+
: routeFileNoExt}.html`),
|
1111
|
+
});
|
1112
|
+
const jsonFsRef =
|
1113
|
+
// JSON data does not exist for fallback or blocking pages
|
1114
|
+
isFallback || isBlocking || (isNotFound && !static404Page)
|
1115
|
+
? null
|
1116
|
+
: new build_utils_1.FileFsRef({
|
1117
|
+
fsPath: path_1.default.join(isAppPathRoute && appDir ? appDir : pagesDir, `${isOmitted || isNotFound
|
1118
|
+
? addLocaleOrDefault('/404.html', routesManifest, locale)
|
1119
|
+
: isAppPathRoute
|
1120
|
+
? dataRoute
|
1121
|
+
: routeFileNoExt + '.json'}`),
|
1122
|
+
});
|
1116
1123
|
const outputPathPage = normalizeIndexOutput(path_1.default.posix.join(entryDirectory, routeFileNoExt), isServerMode);
|
1117
1124
|
const outputPathPageOrig = path_1.default.posix.join(entryDirectory, origRouteFileNoExt);
|
1118
1125
|
let lambda;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.29",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
"@types/semver": "6.0.0",
|
45
45
|
"@types/text-table": "0.2.1",
|
46
46
|
"@types/webpack-sources": "3.2.0",
|
47
|
-
"@vercel/build-utils": "5.
|
47
|
+
"@vercel/build-utils": "5.5.0",
|
48
48
|
"@vercel/nft": "0.22.1",
|
49
49
|
"@vercel/routing-utils": "2.0.2",
|
50
50
|
"async-sema": "3.0.1",
|
@@ -69,5 +69,5 @@
|
|
69
69
|
"typescript": "4.5.2",
|
70
70
|
"webpack-sources": "3.2.3"
|
71
71
|
},
|
72
|
-
"gitHead": "
|
72
|
+
"gitHead": "a825bc95409aa1403e062e45afebe194c8197061"
|
73
73
|
}
|