@vercel/next 3.4.7 → 3.5.1
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 +163 -71
- package/dist/server-build.js +11 -0
- package/dist/utils.js +134 -65
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -40896,10 +40896,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
40896
40896
|
outputDirectory,
|
40897
40897
|
appPathRoutesManifest,
|
40898
40898
|
});
|
40899
|
-
const
|
40900
|
-
.replace(/\\/g, '/')
|
40901
|
-
.match(/(serverless|server)\/pages\/api(\/|\.js$)/);
|
40902
|
-
const canUsePreviewMode = Object.keys(pages).some(page => isApiPage(pages[page].fsPath));
|
40899
|
+
const canUsePreviewMode = Object.keys(pages).some(page => (0, utils_1.isApiPage)(pages[page].fsPath));
|
40903
40900
|
staticPages = await (0, utils_1.filterStaticPages)(await (0, build_utils_1.glob)('**/*.html', pagesDir), dynamicPages, entryDirectory, exports.htmlContentType, prerenderManifest, routesManifest);
|
40904
40901
|
hasStatic500 = !!staticPages[path_1.default.posix.join(entryDirectory, '500')];
|
40905
40902
|
// this can be either 404.html in latest versions
|
@@ -41109,7 +41106,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41109
41106
|
const route = `/${page.replace(/\.js$/, '')}`;
|
41110
41107
|
if (route === '/_error' && static404Page)
|
41111
41108
|
continue;
|
41112
|
-
if (isApiPage(pagePath)) {
|
41109
|
+
if ((0, utils_1.isApiPage)(pagePath)) {
|
41113
41110
|
apiPages.push(page);
|
41114
41111
|
}
|
41115
41112
|
else if (!nonLambdaSsgPages.has(route)) {
|
@@ -41214,6 +41211,9 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41214
41211
|
lambdaCompressedByteLimit,
|
41215
41212
|
internalPages: [],
|
41216
41213
|
});
|
41214
|
+
for (const group of initialApiLambdaGroups) {
|
41215
|
+
group.isApiLambda = true;
|
41216
|
+
}
|
41217
41217
|
(0, build_utils_1.debug)(JSON.stringify({
|
41218
41218
|
apiLambdaGroups: initialApiLambdaGroups.map(group => ({
|
41219
41219
|
pages: group.pages,
|
@@ -41250,7 +41250,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41250
41250
|
const pageFileName = path_1.default.normalize(path_1.default.relative(workPath, pages[page].fsPath));
|
41251
41251
|
const pathname = page.replace(/\.js$/, '');
|
41252
41252
|
const routeIsDynamic = (0, utils_1.isDynamicRoute)(pathname);
|
41253
|
-
routeIsApi = isApiPage(pageFileName);
|
41253
|
+
routeIsApi = (0, utils_1.isApiPage)(pageFileName);
|
41254
41254
|
if (routeIsDynamic) {
|
41255
41255
|
dynamicPages.push((0, utils_1.normalizePage)(pathname));
|
41256
41256
|
}
|
@@ -41366,6 +41366,10 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41366
41366
|
},
|
41367
41367
|
],
|
41368
41368
|
handler: path_1.default.join(path_1.default.relative(baseDir, entryPath), '___next_launcher.cjs'),
|
41369
|
+
operationType: (0, utils_1.getOperationType)({
|
41370
|
+
prerenderManifest,
|
41371
|
+
pageFileName,
|
41372
|
+
}),
|
41369
41373
|
runtime: nodeVersion.runtime,
|
41370
41374
|
nextVersion,
|
41371
41375
|
...lambdaOptions,
|
@@ -41383,6 +41387,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41383
41387
|
},
|
41384
41388
|
],
|
41385
41389
|
handler: path_1.default.join(path_1.default.relative(baseDir, entryPath), '___next_launcher.cjs'),
|
41390
|
+
operationType: (0, utils_1.getOperationType)({ pageFileName }),
|
41386
41391
|
runtime: nodeVersion.runtime,
|
41387
41392
|
nextVersion,
|
41388
41393
|
...lambdaOptions,
|
@@ -41521,6 +41526,10 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41521
41526
|
for (const page of groupPageKeys) {
|
41522
41527
|
pageLambdaMap[page] = group.lambdaIdentifier;
|
41523
41528
|
}
|
41529
|
+
const operationType = (0, utils_1.getOperationType)({
|
41530
|
+
group,
|
41531
|
+
prerenderManifest,
|
41532
|
+
});
|
41524
41533
|
lambdas[group.lambdaIdentifier] =
|
41525
41534
|
await (0, utils_1.createLambdaFromPseudoLayers)({
|
41526
41535
|
files: {
|
@@ -41529,6 +41538,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41529
41538
|
},
|
41530
41539
|
layers: [group.pseudoLayer],
|
41531
41540
|
handler: path_1.default.join(path_1.default.relative(baseDir, entryPath), '___next_launcher.cjs'),
|
41541
|
+
operationType,
|
41532
41542
|
runtime: nodeVersion.runtime,
|
41533
41543
|
nextVersion,
|
41534
41544
|
});
|
@@ -41569,6 +41579,8 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
41569
41579
|
...Object.entries(prerenderManifest.fallbackRoutes),
|
41570
41580
|
...Object.entries(prerenderManifest.blockingFallbackRoutes),
|
41571
41581
|
].forEach(([, { dataRouteRegex, dataRoute }]) => {
|
41582
|
+
if (!dataRoute || !dataRouteRegex)
|
41583
|
+
return;
|
41572
41584
|
dataRoutes.push({
|
41573
41585
|
// Next.js provided data route regex
|
41574
41586
|
src: dataRouteRegex.replace(/^\^/, `^${appMountPrefixNoTrailingSlash}`),
|
@@ -42788,6 +42800,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
42788
42800
|
lambdaCompressedByteLimit,
|
42789
42801
|
internalPages,
|
42790
42802
|
});
|
42803
|
+
for (const group of apiLambdaGroups) {
|
42804
|
+
group.isApiLambda = true;
|
42805
|
+
}
|
42791
42806
|
(0, build_utils_1.debug)(JSON.stringify({
|
42792
42807
|
apiLambdaGroups: apiLambdaGroups.map(group => ({
|
42793
42808
|
pages: group.pages,
|
@@ -42871,6 +42886,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
42871
42886
|
});
|
42872
42887
|
}
|
42873
42888
|
}
|
42889
|
+
const operationType = (0, utils_1.getOperationType)({ group, prerenderManifest });
|
42874
42890
|
const lambda = await (0, utils_1.createLambdaFromPseudoLayers)({
|
42875
42891
|
files: {
|
42876
42892
|
...launcherFiles,
|
@@ -42878,6 +42894,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
42878
42894
|
},
|
42879
42895
|
layers: [group.pseudoLayer, groupPageFiles],
|
42880
42896
|
handler: path_1.default.join(path_1.default.relative(baseDir, requiredServerFilesManifest.appDir || entryPath), '___next_launcher.cjs'),
|
42897
|
+
operationType,
|
42881
42898
|
memory: group.memory,
|
42882
42899
|
runtime: nodeVersion.runtime,
|
42883
42900
|
maxDuration: group.maxDuration,
|
@@ -43045,6 +43062,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
43045
43062
|
}
|
43046
43063
|
}
|
43047
43064
|
const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
|
43065
|
+
const rscVaryHeader = routesManifest?.rsc?.varyHeader ||
|
43066
|
+
'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
|
43048
43067
|
const completeDynamicRoutes = [];
|
43049
43068
|
if (appDir) {
|
43050
43069
|
for (const route of dynamicRoutes) {
|
@@ -43255,7 +43274,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
43255
43274
|
},
|
43256
43275
|
],
|
43257
43276
|
dest: path_1.default.posix.join('/', entryDirectory, '/index.rsc'),
|
43277
|
+
headers: { vary: rscVaryHeader },
|
43258
43278
|
continue: true,
|
43279
|
+
override: true,
|
43259
43280
|
},
|
43260
43281
|
{
|
43261
43282
|
src: `^${path_1.default.posix.join('/', entryDirectory, '/((?!.+\\.rsc).+?)(?:/)?$')}`,
|
@@ -43266,7 +43287,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
43266
43287
|
},
|
43267
43288
|
],
|
43268
43289
|
dest: path_1.default.posix.join('/', entryDirectory, '/$1.rsc'),
|
43290
|
+
headers: { vary: rscVaryHeader },
|
43269
43291
|
continue: true,
|
43292
|
+
override: true,
|
43270
43293
|
},
|
43271
43294
|
]
|
43272
43295
|
: []),
|
@@ -43635,7 +43658,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43635
43658
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
43636
43659
|
};
|
43637
43660
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
43638
|
-
exports.upgradeMiddlewareManifest = exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getImagesConfig = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = exports.prettyBytes = exports.MIB = exports.KIB = void 0;
|
43661
|
+
exports.isApiPage = exports.getOperationType = exports.upgradeMiddlewareManifest = exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getImagesConfig = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = exports.prettyBytes = exports.MIB = exports.KIB = void 0;
|
43639
43662
|
const build_utils_1 = __webpack_require__(3445);
|
43640
43663
|
const async_sema_1 = __webpack_require__(7905);
|
43641
43664
|
const buffer_crc32_1 = __importDefault(__webpack_require__(2227));
|
@@ -44271,7 +44294,8 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
|
|
44271
44294
|
return ret;
|
44272
44295
|
}
|
44273
44296
|
case 2:
|
44274
|
-
case 3:
|
44297
|
+
case 3:
|
44298
|
+
case 4: {
|
44275
44299
|
const routes = Object.keys(manifest.routes);
|
44276
44300
|
const lazyRoutes = Object.keys(manifest.dynamicRoutes);
|
44277
44301
|
const ret = {
|
@@ -44288,12 +44312,20 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
|
|
44288
44312
|
}
|
44289
44313
|
routes.forEach(route => {
|
44290
44314
|
const { initialRevalidateSeconds, dataRoute, srcRoute } = manifest.routes[route];
|
44315
|
+
let initialStatus;
|
44316
|
+
let initialHeaders;
|
44317
|
+
if (manifest.version === 4) {
|
44318
|
+
initialStatus = manifest.routes[route].initialStatus;
|
44319
|
+
initialHeaders = manifest.routes[route].initialHeaders;
|
44320
|
+
}
|
44291
44321
|
ret.staticRoutes[route] = {
|
44292
44322
|
initialRevalidate: initialRevalidateSeconds === false
|
44293
44323
|
? false
|
44294
44324
|
: Math.max(1, initialRevalidateSeconds),
|
44295
44325
|
dataRoute,
|
44296
44326
|
srcRoute,
|
44327
|
+
initialStatus,
|
44328
|
+
initialHeaders,
|
44297
44329
|
};
|
44298
44330
|
});
|
44299
44331
|
lazyRoutes.forEach(lazyRoute => {
|
@@ -44473,6 +44505,7 @@ async function getPageLambdaGroups({ entryPath, config, pages, prerenderRoutes,
|
|
44473
44505
|
pages: [page],
|
44474
44506
|
...opts,
|
44475
44507
|
isPrerenders: isPrerenderRoute,
|
44508
|
+
isApiLambda: !!isApiPage(page),
|
44476
44509
|
pseudoLayerBytes: initialPseudoLayer.pseudoLayerBytes,
|
44477
44510
|
pseudoLayerUncompressedBytes: initialPseudoLayerUncompressed,
|
44478
44511
|
pseudoLayer: Object.assign({}, initialPseudoLayer.pseudoLayer),
|
@@ -44626,7 +44659,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
|
|
44626
44659
|
const pr = prerenderManifest.staticRoutes[routeKey];
|
44627
44660
|
const { initialRevalidate, srcRoute, dataRoute } = pr;
|
44628
44661
|
const route = srcRoute || routeKey;
|
44629
|
-
const isAppPathRoute = appDir && dataRoute?.endsWith('.rsc');
|
44662
|
+
const isAppPathRoute = appDir && (!dataRoute || dataRoute?.endsWith('.rsc'));
|
44630
44663
|
const routeNoLocale = routesManifest?.i18n
|
44631
44664
|
? normalizeLocalePath(routeKey, routesManifest.i18n.locales).pathname
|
44632
44665
|
: routeKey;
|
@@ -44708,6 +44741,8 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44708
44741
|
let initialRevalidate;
|
44709
44742
|
let srcRoute;
|
44710
44743
|
let dataRoute;
|
44744
|
+
let initialStatus;
|
44745
|
+
let initialHeaders;
|
44711
44746
|
if (isFallback || isBlocking) {
|
44712
44747
|
const pr = isFallback
|
44713
44748
|
? prerenderManifest.fallbackRoutes[routeKey]
|
@@ -44731,32 +44766,49 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44731
44766
|
}
|
44732
44767
|
else {
|
44733
44768
|
const pr = prerenderManifest.staticRoutes[routeKey];
|
44734
|
-
({
|
44769
|
+
({
|
44770
|
+
initialRevalidate,
|
44771
|
+
srcRoute,
|
44772
|
+
dataRoute,
|
44773
|
+
initialHeaders,
|
44774
|
+
initialStatus,
|
44775
|
+
} = pr);
|
44735
44776
|
}
|
44736
44777
|
let isAppPathRoute = false;
|
44737
44778
|
// TODO: leverage manifest to determine app paths more accurately
|
44738
|
-
if (appDir && srcRoute && dataRoute
|
44779
|
+
if (appDir && srcRoute && (!dataRoute || dataRoute?.endsWith('.rsc'))) {
|
44739
44780
|
isAppPathRoute = true;
|
44740
44781
|
}
|
44741
44782
|
const isOmittedOrNotFound = isOmitted || isNotFound;
|
44742
|
-
|
44743
|
-
|
44744
|
-
|
44745
|
-
|
44746
|
-
fsPath: path_1.default.join(
|
44747
|
-
|
44748
|
-
: pagesDir, isFallback
|
44749
|
-
? // Fallback pages have a special file.
|
44750
|
-
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
44751
|
-
: // Otherwise, the route itself should exist as a static HTML
|
44752
|
-
// file.
|
44753
|
-
`${isOmittedOrNotFound
|
44754
|
-
? addLocaleOrDefault('/404', routesManifest, locale)
|
44755
|
-
: routeFileNoExt}.html`),
|
44783
|
+
let htmlFsRef;
|
44784
|
+
if (appDir && !dataRoute && isAppPathRoute && !(isBlocking || isFallback)) {
|
44785
|
+
const contentType = initialHeaders?.['content-type'];
|
44786
|
+
htmlFsRef = new build_utils_1.FileFsRef({
|
44787
|
+
fsPath: path_1.default.join(appDir, `${routeFileNoExt}.body`),
|
44788
|
+
contentType: contentType || 'text/html;charset=utf-8',
|
44756
44789
|
});
|
44790
|
+
}
|
44791
|
+
else {
|
44792
|
+
htmlFsRef =
|
44793
|
+
isBlocking || (isNotFound && !static404Page)
|
44794
|
+
? // Blocking pages do not have an HTML fallback
|
44795
|
+
null
|
44796
|
+
: new build_utils_1.FileFsRef({
|
44797
|
+
fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
|
44798
|
+
? appDir
|
44799
|
+
: pagesDir, isFallback
|
44800
|
+
? // Fallback pages have a special file.
|
44801
|
+
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
44802
|
+
: // Otherwise, the route itself should exist as a static HTML
|
44803
|
+
// file.
|
44804
|
+
`${isOmittedOrNotFound
|
44805
|
+
? addLocaleOrDefault('/404', routesManifest, locale)
|
44806
|
+
: routeFileNoExt}.html`),
|
44807
|
+
});
|
44808
|
+
}
|
44757
44809
|
const jsonFsRef =
|
44758
44810
|
// JSON data does not exist for fallback or blocking pages
|
44759
|
-
isFallback || isBlocking || (isNotFound && !static404Page)
|
44811
|
+
isFallback || isBlocking || (isNotFound && !static404Page) || !dataRoute
|
44760
44812
|
? null
|
44761
44813
|
: new build_utils_1.FileFsRef({
|
44762
44814
|
fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
|
@@ -44782,13 +44834,16 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44782
44834
|
}
|
44783
44835
|
const outputPathPageOrig = path_1.default.posix.join(entryDirectory, origRouteFileNoExt);
|
44784
44836
|
let lambda;
|
44785
|
-
let outputPathData =
|
44786
|
-
if (
|
44787
|
-
outputPathData =
|
44788
|
-
|
44789
|
-
|
44790
|
-
|
44791
|
-
|
44837
|
+
let outputPathData = null;
|
44838
|
+
if (dataRoute) {
|
44839
|
+
outputPathData = path_1.default.posix.join(entryDirectory, dataRoute);
|
44840
|
+
if (nonDynamicSsg || isFallback || isOmitted) {
|
44841
|
+
outputPathData = outputPathData.replace(new RegExp(`${(0, escape_string_regexp_1.default)(origRouteFileNoExt)}.json$`),
|
44842
|
+
// ensure we escape "$" correctly while replacing as "$" is a special
|
44843
|
+
// character, we need to do double escaping as first is for the initial
|
44844
|
+
// replace on the routeFile and then the second on the outputPath
|
44845
|
+
`${routeFileNoExt.replace(/\$/g, '$$$$')}.json`);
|
44846
|
+
}
|
44792
44847
|
}
|
44793
44848
|
if (isSharedLambdas) {
|
44794
44849
|
const outputSrcPathPage = normalizeIndexOutput(path_1.default.join('/', srcRoute == null
|
@@ -44807,7 +44862,7 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44807
44862
|
if (htmlFsRef == null || jsonFsRef == null) {
|
44808
44863
|
throw new build_utils_1.NowBuildError({
|
44809
44864
|
code: 'NEXT_HTMLFSREF_JSONFSREF',
|
44810
|
-
message:
|
44865
|
+
message: `invariant: htmlFsRef != null && jsonFsRef != null ${routeFileNoExt}`,
|
44811
44866
|
});
|
44812
44867
|
}
|
44813
44868
|
// if preview mode/On-Demand ISR can't be leveraged
|
@@ -44816,7 +44871,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44816
44871
|
(routeKey === '/404' && !lambdas[outputPathPage])) {
|
44817
44872
|
htmlFsRef.contentType = _1.htmlContentType;
|
44818
44873
|
prerenders[outputPathPage] = htmlFsRef;
|
44819
|
-
|
44874
|
+
if (outputPathData) {
|
44875
|
+
prerenders[outputPathData] = jsonFsRef;
|
44876
|
+
}
|
44820
44877
|
}
|
44821
44878
|
}
|
44822
44879
|
const isNotFoundPreview = isCorrectNotFoundRoutes &&
|
@@ -44870,9 +44927,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44870
44927
|
allowQuery = [];
|
44871
44928
|
}
|
44872
44929
|
}
|
44873
|
-
const
|
44874
|
-
|
44875
|
-
const rscContentTypeHeader = routesManifest?.rsc?.contentTypeHeader || '
|
44930
|
+
const rscEnabled = !!routesManifest?.rsc;
|
44931
|
+
const rscVaryHeader = routesManifest?.rsc?.varyHeader || 'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
|
44932
|
+
const rscContentTypeHeader = routesManifest?.rsc?.contentTypeHeader || 'text/x-component';
|
44876
44933
|
prerenders[outputPathPage] = new build_utils_1.Prerender({
|
44877
44934
|
expiration: initialRevalidate,
|
44878
44935
|
lambda,
|
@@ -44880,59 +44937,66 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
44880
44937
|
fallback: htmlFsRef,
|
44881
44938
|
group: prerenderGroup,
|
44882
44939
|
bypassToken: prerenderManifest.bypassToken,
|
44940
|
+
initialStatus,
|
44941
|
+
initialHeaders,
|
44883
44942
|
...(isNotFound
|
44884
44943
|
? {
|
44885
44944
|
initialStatus: 404,
|
44886
44945
|
}
|
44887
44946
|
: {}),
|
44888
|
-
...(
|
44947
|
+
...(rscEnabled
|
44889
44948
|
? {
|
44890
44949
|
initialHeaders: {
|
44950
|
+
...initialHeaders,
|
44891
44951
|
vary: rscVaryHeader,
|
44892
44952
|
},
|
44893
44953
|
}
|
44894
44954
|
: {}),
|
44895
44955
|
});
|
44896
|
-
|
44897
|
-
|
44898
|
-
|
44899
|
-
|
44900
|
-
|
44901
|
-
|
44902
|
-
|
44903
|
-
|
44904
|
-
|
44905
|
-
|
44906
|
-
|
44907
|
-
|
44908
|
-
|
44909
|
-
|
44910
|
-
|
44911
|
-
|
44912
|
-
|
44913
|
-
|
44914
|
-
|
44915
|
-
|
44916
|
-
|
44956
|
+
if (outputPathData) {
|
44957
|
+
prerenders[outputPathData] = new build_utils_1.Prerender({
|
44958
|
+
expiration: initialRevalidate,
|
44959
|
+
lambda,
|
44960
|
+
allowQuery,
|
44961
|
+
fallback: jsonFsRef,
|
44962
|
+
group: prerenderGroup,
|
44963
|
+
bypassToken: prerenderManifest.bypassToken,
|
44964
|
+
...(isNotFound
|
44965
|
+
? {
|
44966
|
+
initialStatus: 404,
|
44967
|
+
}
|
44968
|
+
: {}),
|
44969
|
+
...(rscEnabled
|
44970
|
+
? {
|
44971
|
+
initialHeaders: {
|
44972
|
+
'content-type': rscContentTypeHeader,
|
44973
|
+
vary: rscVaryHeader,
|
44974
|
+
},
|
44975
|
+
}
|
44976
|
+
: {}),
|
44977
|
+
});
|
44978
|
+
}
|
44917
44979
|
++prerenderGroup;
|
44918
44980
|
if (routesManifest?.i18n && isBlocking) {
|
44919
44981
|
for (const locale of routesManifest.i18n.locales) {
|
44920
44982
|
const localeRouteFileNoExt = addLocaleOrDefault(routeFileNoExt, routesManifest, locale);
|
44921
44983
|
const localeOutputPathPage = normalizeIndexOutput(path_1.default.posix.join(entryDirectory, localeRouteFileNoExt), isServerMode);
|
44922
|
-
const localeOutputPathData = outputPathData.replace(new RegExp(`${(0, escape_string_regexp_1.default)(origRouteFileNoExt)}.json$`), `${localeRouteFileNoExt}${localeRouteFileNoExt !== origRouteFileNoExt &&
|
44923
|
-
origRouteFileNoExt === '/index'
|
44924
|
-
? '/index'
|
44925
|
-
: ''}.json`);
|
44926
44984
|
const origPrerenderPage = prerenders[outputPathPage];
|
44927
|
-
const origPrerenderData = prerenders[outputPathData];
|
44928
44985
|
prerenders[localeOutputPathPage] = {
|
44929
44986
|
...origPrerenderPage,
|
44930
44987
|
group: prerenderGroup,
|
44931
44988
|
};
|
44932
|
-
|
44933
|
-
|
44934
|
-
|
44935
|
-
|
44989
|
+
if (outputPathData) {
|
44990
|
+
const localeOutputPathData = outputPathData.replace(new RegExp(`${(0, escape_string_regexp_1.default)(origRouteFileNoExt)}.json$`), `${localeRouteFileNoExt}${localeRouteFileNoExt !== origRouteFileNoExt &&
|
44991
|
+
origRouteFileNoExt === '/index'
|
44992
|
+
? '/index'
|
44993
|
+
: ''}.json`);
|
44994
|
+
const origPrerenderData = prerenders[outputPathData];
|
44995
|
+
prerenders[localeOutputPathData] = {
|
44996
|
+
...origPrerenderData,
|
44997
|
+
group: prerenderGroup,
|
44998
|
+
};
|
44999
|
+
}
|
44936
45000
|
++prerenderGroup;
|
44937
45001
|
}
|
44938
45002
|
}
|
@@ -45164,9 +45228,11 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
45164
45228
|
if (shortPath.startsWith('pages/')) {
|
45165
45229
|
shortPath = shortPath.replace(/^pages\//, '');
|
45166
45230
|
}
|
45167
|
-
else if (shortPath.startsWith('app/') &&
|
45231
|
+
else if (shortPath.startsWith('app/') &&
|
45232
|
+
(shortPath.endsWith('/page') || shortPath.endsWith('/route'))) {
|
45168
45233
|
shortPath =
|
45169
|
-
shortPath.replace(/^app\//, '').replace(/(^|\/)page$/, '') ||
|
45234
|
+
shortPath.replace(/^app\//, '').replace(/(^|\/)(page|route)$/, '') ||
|
45235
|
+
'index';
|
45170
45236
|
}
|
45171
45237
|
if (routesManifest?.basePath) {
|
45172
45238
|
shortPath = path_1.default.posix
|
@@ -45314,6 +45380,32 @@ function transformSourceMap(sourcemap) {
|
|
45314
45380
|
});
|
45315
45381
|
return { ...sourcemap, sources };
|
45316
45382
|
}
|
45383
|
+
function getOperationType({ group, prerenderManifest, pageFileName, }) {
|
45384
|
+
if (group?.isApiLambda || isApiPage(pageFileName)) {
|
45385
|
+
return 'API';
|
45386
|
+
}
|
45387
|
+
if (group?.isPrerenders) {
|
45388
|
+
return 'ISR';
|
45389
|
+
}
|
45390
|
+
if (pageFileName && prerenderManifest) {
|
45391
|
+
const { blockingFallbackRoutes = {}, fallbackRoutes = {} } = prerenderManifest;
|
45392
|
+
if (pageFileName in blockingFallbackRoutes ||
|
45393
|
+
pageFileName in fallbackRoutes) {
|
45394
|
+
return 'ISR';
|
45395
|
+
}
|
45396
|
+
}
|
45397
|
+
return 'SSR';
|
45398
|
+
}
|
45399
|
+
exports.getOperationType = getOperationType;
|
45400
|
+
function isApiPage(page) {
|
45401
|
+
if (!page) {
|
45402
|
+
return false;
|
45403
|
+
}
|
45404
|
+
return page
|
45405
|
+
.replace(/\\/g, '/')
|
45406
|
+
.match(/(serverless|server)\/pages\/api(\/|\.js$)/);
|
45407
|
+
}
|
45408
|
+
exports.isApiPage = isApiPage;
|
45317
45409
|
|
45318
45410
|
|
45319
45411
|
/***/ }),
|
package/dist/server-build.js
CHANGED
@@ -412,6 +412,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
412
412
|
lambdaCompressedByteLimit,
|
413
413
|
internalPages,
|
414
414
|
});
|
415
|
+
for (const group of apiLambdaGroups) {
|
416
|
+
group.isApiLambda = true;
|
417
|
+
}
|
415
418
|
(0, build_utils_1.debug)(JSON.stringify({
|
416
419
|
apiLambdaGroups: apiLambdaGroups.map(group => ({
|
417
420
|
pages: group.pages,
|
@@ -495,6 +498,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
495
498
|
});
|
496
499
|
}
|
497
500
|
}
|
501
|
+
const operationType = (0, utils_1.getOperationType)({ group, prerenderManifest });
|
498
502
|
const lambda = await (0, utils_1.createLambdaFromPseudoLayers)({
|
499
503
|
files: {
|
500
504
|
...launcherFiles,
|
@@ -502,6 +506,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
502
506
|
},
|
503
507
|
layers: [group.pseudoLayer, groupPageFiles],
|
504
508
|
handler: path_1.default.join(path_1.default.relative(baseDir, requiredServerFilesManifest.appDir || entryPath), '___next_launcher.cjs'),
|
509
|
+
operationType,
|
505
510
|
memory: group.memory,
|
506
511
|
runtime: nodeVersion.runtime,
|
507
512
|
maxDuration: group.maxDuration,
|
@@ -669,6 +674,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
669
674
|
}
|
670
675
|
}
|
671
676
|
const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
|
677
|
+
const rscVaryHeader = routesManifest?.rsc?.varyHeader ||
|
678
|
+
'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
|
672
679
|
const completeDynamicRoutes = [];
|
673
680
|
if (appDir) {
|
674
681
|
for (const route of dynamicRoutes) {
|
@@ -879,7 +886,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
879
886
|
},
|
880
887
|
],
|
881
888
|
dest: path_1.default.posix.join('/', entryDirectory, '/index.rsc'),
|
889
|
+
headers: { vary: rscVaryHeader },
|
882
890
|
continue: true,
|
891
|
+
override: true,
|
883
892
|
},
|
884
893
|
{
|
885
894
|
src: `^${path_1.default.posix.join('/', entryDirectory, '/((?!.+\\.rsc).+?)(?:/)?$')}`,
|
@@ -890,7 +899,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
890
899
|
},
|
891
900
|
],
|
892
901
|
dest: path_1.default.posix.join('/', entryDirectory, '/$1.rsc'),
|
902
|
+
headers: { vary: rscVaryHeader },
|
893
903
|
continue: true,
|
904
|
+
override: true,
|
894
905
|
},
|
895
906
|
]
|
896
907
|
: []),
|
package/dist/utils.js
CHANGED
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
23
|
};
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
-
exports.upgradeMiddlewareManifest = exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getImagesConfig = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = exports.prettyBytes = exports.MIB = exports.KIB = void 0;
|
25
|
+
exports.isApiPage = exports.getOperationType = exports.upgradeMiddlewareManifest = exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getImagesConfig = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = exports.prettyBytes = exports.MIB = exports.KIB = void 0;
|
26
26
|
const build_utils_1 = require("@vercel/build-utils");
|
27
27
|
const async_sema_1 = require("async-sema");
|
28
28
|
const buffer_crc32_1 = __importDefault(require("buffer-crc32"));
|
@@ -658,7 +658,8 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
|
|
658
658
|
return ret;
|
659
659
|
}
|
660
660
|
case 2:
|
661
|
-
case 3:
|
661
|
+
case 3:
|
662
|
+
case 4: {
|
662
663
|
const routes = Object.keys(manifest.routes);
|
663
664
|
const lazyRoutes = Object.keys(manifest.dynamicRoutes);
|
664
665
|
const ret = {
|
@@ -675,12 +676,20 @@ async function getPrerenderManifest(entryPath, outputDirectory) {
|
|
675
676
|
}
|
676
677
|
routes.forEach(route => {
|
677
678
|
const { initialRevalidateSeconds, dataRoute, srcRoute } = manifest.routes[route];
|
679
|
+
let initialStatus;
|
680
|
+
let initialHeaders;
|
681
|
+
if (manifest.version === 4) {
|
682
|
+
initialStatus = manifest.routes[route].initialStatus;
|
683
|
+
initialHeaders = manifest.routes[route].initialHeaders;
|
684
|
+
}
|
678
685
|
ret.staticRoutes[route] = {
|
679
686
|
initialRevalidate: initialRevalidateSeconds === false
|
680
687
|
? false
|
681
688
|
: Math.max(1, initialRevalidateSeconds),
|
682
689
|
dataRoute,
|
683
690
|
srcRoute,
|
691
|
+
initialStatus,
|
692
|
+
initialHeaders,
|
684
693
|
};
|
685
694
|
});
|
686
695
|
lazyRoutes.forEach(lazyRoute => {
|
@@ -860,6 +869,7 @@ async function getPageLambdaGroups({ entryPath, config, pages, prerenderRoutes,
|
|
860
869
|
pages: [page],
|
861
870
|
...opts,
|
862
871
|
isPrerenders: isPrerenderRoute,
|
872
|
+
isApiLambda: !!isApiPage(page),
|
863
873
|
pseudoLayerBytes: initialPseudoLayer.pseudoLayerBytes,
|
864
874
|
pseudoLayerUncompressedBytes: initialPseudoLayerUncompressed,
|
865
875
|
pseudoLayer: Object.assign({}, initialPseudoLayer.pseudoLayer),
|
@@ -1013,7 +1023,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
|
|
1013
1023
|
const pr = prerenderManifest.staticRoutes[routeKey];
|
1014
1024
|
const { initialRevalidate, srcRoute, dataRoute } = pr;
|
1015
1025
|
const route = srcRoute || routeKey;
|
1016
|
-
const isAppPathRoute = appDir && dataRoute?.endsWith('.rsc');
|
1026
|
+
const isAppPathRoute = appDir && (!dataRoute || dataRoute?.endsWith('.rsc'));
|
1017
1027
|
const routeNoLocale = routesManifest?.i18n
|
1018
1028
|
? normalizeLocalePath(routeKey, routesManifest.i18n.locales).pathname
|
1019
1029
|
: routeKey;
|
@@ -1095,6 +1105,8 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1095
1105
|
let initialRevalidate;
|
1096
1106
|
let srcRoute;
|
1097
1107
|
let dataRoute;
|
1108
|
+
let initialStatus;
|
1109
|
+
let initialHeaders;
|
1098
1110
|
if (isFallback || isBlocking) {
|
1099
1111
|
const pr = isFallback
|
1100
1112
|
? prerenderManifest.fallbackRoutes[routeKey]
|
@@ -1118,32 +1130,49 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1118
1130
|
}
|
1119
1131
|
else {
|
1120
1132
|
const pr = prerenderManifest.staticRoutes[routeKey];
|
1121
|
-
({
|
1133
|
+
({
|
1134
|
+
initialRevalidate,
|
1135
|
+
srcRoute,
|
1136
|
+
dataRoute,
|
1137
|
+
initialHeaders,
|
1138
|
+
initialStatus,
|
1139
|
+
} = pr);
|
1122
1140
|
}
|
1123
1141
|
let isAppPathRoute = false;
|
1124
1142
|
// TODO: leverage manifest to determine app paths more accurately
|
1125
|
-
if (appDir && srcRoute && dataRoute
|
1143
|
+
if (appDir && srcRoute && (!dataRoute || dataRoute?.endsWith('.rsc'))) {
|
1126
1144
|
isAppPathRoute = true;
|
1127
1145
|
}
|
1128
1146
|
const isOmittedOrNotFound = isOmitted || isNotFound;
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
fsPath: path_1.default.join(
|
1134
|
-
|
1135
|
-
: pagesDir, isFallback
|
1136
|
-
? // Fallback pages have a special file.
|
1137
|
-
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
1138
|
-
: // Otherwise, the route itself should exist as a static HTML
|
1139
|
-
// file.
|
1140
|
-
`${isOmittedOrNotFound
|
1141
|
-
? addLocaleOrDefault('/404', routesManifest, locale)
|
1142
|
-
: routeFileNoExt}.html`),
|
1147
|
+
let htmlFsRef;
|
1148
|
+
if (appDir && !dataRoute && isAppPathRoute && !(isBlocking || isFallback)) {
|
1149
|
+
const contentType = initialHeaders?.['content-type'];
|
1150
|
+
htmlFsRef = new build_utils_1.FileFsRef({
|
1151
|
+
fsPath: path_1.default.join(appDir, `${routeFileNoExt}.body`),
|
1152
|
+
contentType: contentType || 'text/html;charset=utf-8',
|
1143
1153
|
});
|
1154
|
+
}
|
1155
|
+
else {
|
1156
|
+
htmlFsRef =
|
1157
|
+
isBlocking || (isNotFound && !static404Page)
|
1158
|
+
? // Blocking pages do not have an HTML fallback
|
1159
|
+
null
|
1160
|
+
: new build_utils_1.FileFsRef({
|
1161
|
+
fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
|
1162
|
+
? appDir
|
1163
|
+
: pagesDir, isFallback
|
1164
|
+
? // Fallback pages have a special file.
|
1165
|
+
addLocaleOrDefault(prerenderManifest.fallbackRoutes[routeKey].fallback, routesManifest, locale)
|
1166
|
+
: // Otherwise, the route itself should exist as a static HTML
|
1167
|
+
// file.
|
1168
|
+
`${isOmittedOrNotFound
|
1169
|
+
? addLocaleOrDefault('/404', routesManifest, locale)
|
1170
|
+
: routeFileNoExt}.html`),
|
1171
|
+
});
|
1172
|
+
}
|
1144
1173
|
const jsonFsRef =
|
1145
1174
|
// JSON data does not exist for fallback or blocking pages
|
1146
|
-
isFallback || isBlocking || (isNotFound && !static404Page)
|
1175
|
+
isFallback || isBlocking || (isNotFound && !static404Page) || !dataRoute
|
1147
1176
|
? null
|
1148
1177
|
: new build_utils_1.FileFsRef({
|
1149
1178
|
fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
|
@@ -1169,13 +1198,16 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1169
1198
|
}
|
1170
1199
|
const outputPathPageOrig = path_1.default.posix.join(entryDirectory, origRouteFileNoExt);
|
1171
1200
|
let lambda;
|
1172
|
-
let outputPathData =
|
1173
|
-
if (
|
1174
|
-
outputPathData =
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1201
|
+
let outputPathData = null;
|
1202
|
+
if (dataRoute) {
|
1203
|
+
outputPathData = path_1.default.posix.join(entryDirectory, dataRoute);
|
1204
|
+
if (nonDynamicSsg || isFallback || isOmitted) {
|
1205
|
+
outputPathData = outputPathData.replace(new RegExp(`${(0, escape_string_regexp_1.default)(origRouteFileNoExt)}.json$`),
|
1206
|
+
// ensure we escape "$" correctly while replacing as "$" is a special
|
1207
|
+
// character, we need to do double escaping as first is for the initial
|
1208
|
+
// replace on the routeFile and then the second on the outputPath
|
1209
|
+
`${routeFileNoExt.replace(/\$/g, '$$$$')}.json`);
|
1210
|
+
}
|
1179
1211
|
}
|
1180
1212
|
if (isSharedLambdas) {
|
1181
1213
|
const outputSrcPathPage = normalizeIndexOutput(path_1.default.join('/', srcRoute == null
|
@@ -1194,7 +1226,7 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1194
1226
|
if (htmlFsRef == null || jsonFsRef == null) {
|
1195
1227
|
throw new build_utils_1.NowBuildError({
|
1196
1228
|
code: 'NEXT_HTMLFSREF_JSONFSREF',
|
1197
|
-
message:
|
1229
|
+
message: `invariant: htmlFsRef != null && jsonFsRef != null ${routeFileNoExt}`,
|
1198
1230
|
});
|
1199
1231
|
}
|
1200
1232
|
// if preview mode/On-Demand ISR can't be leveraged
|
@@ -1203,7 +1235,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1203
1235
|
(routeKey === '/404' && !lambdas[outputPathPage])) {
|
1204
1236
|
htmlFsRef.contentType = _1.htmlContentType;
|
1205
1237
|
prerenders[outputPathPage] = htmlFsRef;
|
1206
|
-
|
1238
|
+
if (outputPathData) {
|
1239
|
+
prerenders[outputPathData] = jsonFsRef;
|
1240
|
+
}
|
1207
1241
|
}
|
1208
1242
|
}
|
1209
1243
|
const isNotFoundPreview = isCorrectNotFoundRoutes &&
|
@@ -1257,9 +1291,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1257
1291
|
allowQuery = [];
|
1258
1292
|
}
|
1259
1293
|
}
|
1260
|
-
const
|
1261
|
-
|
1262
|
-
const rscContentTypeHeader = routesManifest?.rsc?.contentTypeHeader || '
|
1294
|
+
const rscEnabled = !!routesManifest?.rsc;
|
1295
|
+
const rscVaryHeader = routesManifest?.rsc?.varyHeader || 'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
|
1296
|
+
const rscContentTypeHeader = routesManifest?.rsc?.contentTypeHeader || 'text/x-component';
|
1263
1297
|
prerenders[outputPathPage] = new build_utils_1.Prerender({
|
1264
1298
|
expiration: initialRevalidate,
|
1265
1299
|
lambda,
|
@@ -1267,59 +1301,66 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1267
1301
|
fallback: htmlFsRef,
|
1268
1302
|
group: prerenderGroup,
|
1269
1303
|
bypassToken: prerenderManifest.bypassToken,
|
1304
|
+
initialStatus,
|
1305
|
+
initialHeaders,
|
1270
1306
|
...(isNotFound
|
1271
1307
|
? {
|
1272
1308
|
initialStatus: 404,
|
1273
1309
|
}
|
1274
1310
|
: {}),
|
1275
|
-
...(
|
1276
|
-
? {
|
1277
|
-
initialHeaders: {
|
1278
|
-
vary: rscVaryHeader,
|
1279
|
-
},
|
1280
|
-
}
|
1281
|
-
: {}),
|
1282
|
-
});
|
1283
|
-
prerenders[outputPathData] = new build_utils_1.Prerender({
|
1284
|
-
expiration: initialRevalidate,
|
1285
|
-
lambda,
|
1286
|
-
allowQuery,
|
1287
|
-
fallback: jsonFsRef,
|
1288
|
-
group: prerenderGroup,
|
1289
|
-
bypassToken: prerenderManifest.bypassToken,
|
1290
|
-
...(isNotFound
|
1291
|
-
? {
|
1292
|
-
initialStatus: 404,
|
1293
|
-
}
|
1294
|
-
: {}),
|
1295
|
-
...(isAppPathRoute
|
1311
|
+
...(rscEnabled
|
1296
1312
|
? {
|
1297
1313
|
initialHeaders: {
|
1298
|
-
|
1314
|
+
...initialHeaders,
|
1299
1315
|
vary: rscVaryHeader,
|
1300
1316
|
},
|
1301
1317
|
}
|
1302
1318
|
: {}),
|
1303
1319
|
});
|
1320
|
+
if (outputPathData) {
|
1321
|
+
prerenders[outputPathData] = new build_utils_1.Prerender({
|
1322
|
+
expiration: initialRevalidate,
|
1323
|
+
lambda,
|
1324
|
+
allowQuery,
|
1325
|
+
fallback: jsonFsRef,
|
1326
|
+
group: prerenderGroup,
|
1327
|
+
bypassToken: prerenderManifest.bypassToken,
|
1328
|
+
...(isNotFound
|
1329
|
+
? {
|
1330
|
+
initialStatus: 404,
|
1331
|
+
}
|
1332
|
+
: {}),
|
1333
|
+
...(rscEnabled
|
1334
|
+
? {
|
1335
|
+
initialHeaders: {
|
1336
|
+
'content-type': rscContentTypeHeader,
|
1337
|
+
vary: rscVaryHeader,
|
1338
|
+
},
|
1339
|
+
}
|
1340
|
+
: {}),
|
1341
|
+
});
|
1342
|
+
}
|
1304
1343
|
++prerenderGroup;
|
1305
1344
|
if (routesManifest?.i18n && isBlocking) {
|
1306
1345
|
for (const locale of routesManifest.i18n.locales) {
|
1307
1346
|
const localeRouteFileNoExt = addLocaleOrDefault(routeFileNoExt, routesManifest, locale);
|
1308
1347
|
const localeOutputPathPage = normalizeIndexOutput(path_1.default.posix.join(entryDirectory, localeRouteFileNoExt), isServerMode);
|
1309
|
-
const localeOutputPathData = outputPathData.replace(new RegExp(`${(0, escape_string_regexp_1.default)(origRouteFileNoExt)}.json$`), `${localeRouteFileNoExt}${localeRouteFileNoExt !== origRouteFileNoExt &&
|
1310
|
-
origRouteFileNoExt === '/index'
|
1311
|
-
? '/index'
|
1312
|
-
: ''}.json`);
|
1313
1348
|
const origPrerenderPage = prerenders[outputPathPage];
|
1314
|
-
const origPrerenderData = prerenders[outputPathData];
|
1315
1349
|
prerenders[localeOutputPathPage] = {
|
1316
1350
|
...origPrerenderPage,
|
1317
1351
|
group: prerenderGroup,
|
1318
1352
|
};
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1353
|
+
if (outputPathData) {
|
1354
|
+
const localeOutputPathData = outputPathData.replace(new RegExp(`${(0, escape_string_regexp_1.default)(origRouteFileNoExt)}.json$`), `${localeRouteFileNoExt}${localeRouteFileNoExt !== origRouteFileNoExt &&
|
1355
|
+
origRouteFileNoExt === '/index'
|
1356
|
+
? '/index'
|
1357
|
+
: ''}.json`);
|
1358
|
+
const origPrerenderData = prerenders[outputPathData];
|
1359
|
+
prerenders[localeOutputPathData] = {
|
1360
|
+
...origPrerenderData,
|
1361
|
+
group: prerenderGroup,
|
1362
|
+
};
|
1363
|
+
}
|
1323
1364
|
++prerenderGroup;
|
1324
1365
|
}
|
1325
1366
|
}
|
@@ -1551,9 +1592,11 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1551
1592
|
if (shortPath.startsWith('pages/')) {
|
1552
1593
|
shortPath = shortPath.replace(/^pages\//, '');
|
1553
1594
|
}
|
1554
|
-
else if (shortPath.startsWith('app/') &&
|
1595
|
+
else if (shortPath.startsWith('app/') &&
|
1596
|
+
(shortPath.endsWith('/page') || shortPath.endsWith('/route'))) {
|
1555
1597
|
shortPath =
|
1556
|
-
shortPath.replace(/^app\//, '').replace(/(^|\/)page$/, '') ||
|
1598
|
+
shortPath.replace(/^app\//, '').replace(/(^|\/)(page|route)$/, '') ||
|
1599
|
+
'index';
|
1557
1600
|
}
|
1558
1601
|
if (routesManifest?.basePath) {
|
1559
1602
|
shortPath = path_1.default.posix
|
@@ -1701,3 +1744,29 @@ function transformSourceMap(sourcemap) {
|
|
1701
1744
|
});
|
1702
1745
|
return { ...sourcemap, sources };
|
1703
1746
|
}
|
1747
|
+
function getOperationType({ group, prerenderManifest, pageFileName, }) {
|
1748
|
+
if (group?.isApiLambda || isApiPage(pageFileName)) {
|
1749
|
+
return 'API';
|
1750
|
+
}
|
1751
|
+
if (group?.isPrerenders) {
|
1752
|
+
return 'ISR';
|
1753
|
+
}
|
1754
|
+
if (pageFileName && prerenderManifest) {
|
1755
|
+
const { blockingFallbackRoutes = {}, fallbackRoutes = {} } = prerenderManifest;
|
1756
|
+
if (pageFileName in blockingFallbackRoutes ||
|
1757
|
+
pageFileName in fallbackRoutes) {
|
1758
|
+
return 'ISR';
|
1759
|
+
}
|
1760
|
+
}
|
1761
|
+
return 'SSR';
|
1762
|
+
}
|
1763
|
+
exports.getOperationType = getOperationType;
|
1764
|
+
function isApiPage(page) {
|
1765
|
+
if (!page) {
|
1766
|
+
return false;
|
1767
|
+
}
|
1768
|
+
return page
|
1769
|
+
.replace(/\\/g, '/')
|
1770
|
+
.match(/(serverless|server)\/pages\/api(\/|\.js$)/);
|
1771
|
+
}
|
1772
|
+
exports.isApiPage = isApiPage;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.5.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
@@ -71,5 +71,5 @@
|
|
71
71
|
"typescript": "4.5.2",
|
72
72
|
"webpack-sources": "3.2.3"
|
73
73
|
},
|
74
|
-
"gitHead": "
|
74
|
+
"gitHead": "2fd33152219e7a2485b85b698e339c9c5cee23cf"
|
75
75
|
}
|