@vercel/next 3.9.0 → 3.9.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 +20 -9
- package/dist/server-build.js +8 -4
- package/dist/utils.js +12 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -43145,15 +43145,17 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
43145
43145
|
};
|
43146
43146
|
const { i18n } = routesManifest;
|
43147
43147
|
const hasPages404 = routesManifest.pages404;
|
43148
|
+
let localePrefixed404 = false;
|
43148
43149
|
let static404Page = staticPages[path_1.default.posix.join(entryDirectory, '404')] && hasPages404
|
43149
43150
|
? path_1.default.posix.join(entryDirectory, '404')
|
43150
43151
|
: staticPages[path_1.default.posix.join(entryDirectory, '_errors/404')]
|
43151
43152
|
? path_1.default.posix.join(entryDirectory, '_errors/404')
|
43152
43153
|
: undefined;
|
43153
43154
|
if (!static404Page && i18n) {
|
43154
|
-
|
43155
|
-
|
43156
|
-
|
43155
|
+
if (staticPages[path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')]) {
|
43156
|
+
localePrefixed404 = true;
|
43157
|
+
static404Page = path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404');
|
43158
|
+
}
|
43157
43159
|
}
|
43158
43160
|
if (!hasStatic500 && i18n) {
|
43159
43161
|
hasStatic500 =
|
@@ -43642,6 +43644,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
43642
43644
|
// this is handled in onPrerenderRoute for SSG pages
|
43643
43645
|
if (i18n &&
|
43644
43646
|
!isPrerender &&
|
43647
|
+
!group.isAppRouter &&
|
43645
43648
|
(!isCorrectLocaleAPIRoutes ||
|
43646
43649
|
!(pageNoExt === 'api' || pageNoExt.startsWith('api/')))) {
|
43647
43650
|
for (const locale of i18n.locales) {
|
@@ -43669,6 +43672,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
43669
43672
|
isSharedLambdas: false,
|
43670
43673
|
canUsePreviewMode,
|
43671
43674
|
static404Page,
|
43675
|
+
localePrefixed404,
|
43672
43676
|
hasPages404: routesManifest.pages404,
|
43673
43677
|
isCorrectNotFoundRoutes,
|
43674
43678
|
isEmptyAllowQueryForPrendered,
|
@@ -43699,7 +43703,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
43699
43703
|
});
|
43700
43704
|
const isNextDataServerResolving = middleware.staticRoutes.length > 0 &&
|
43701
43705
|
semver_1.default.gte(nextVersion, NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION);
|
43702
|
-
const dynamicRoutes = await (0, utils_1.getDynamicRoutes)(entryPath, entryDirectory, dynamicPages, false, routesManifest, omittedPrerenderRoutes, canUsePreviewMode, prerenderManifest.bypassToken || '', true, middleware.dynamicRouteMap, inversedAppPathManifest).then(arr => (0, utils_1.localizeDynamicRoutes)(arr, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, true, isCorrectLocaleAPIRoutes));
|
43706
|
+
const dynamicRoutes = await (0, utils_1.getDynamicRoutes)(entryPath, entryDirectory, dynamicPages, false, routesManifest, omittedPrerenderRoutes, canUsePreviewMode, prerenderManifest.bypassToken || '', true, middleware.dynamicRouteMap, inversedAppPathManifest).then(arr => (0, utils_1.localizeDynamicRoutes)(arr, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, true, isCorrectLocaleAPIRoutes, inversedAppPathManifest));
|
43703
43707
|
const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await (0, utils_1.getStaticFiles)(entryPath, entryDirectory, outputDirectory);
|
43704
43708
|
const normalizeNextDataRoute = (isOverride = false) => {
|
43705
43709
|
return isNextDataServerResolving
|
@@ -44694,7 +44698,7 @@ async function getDynamicRoutes(entryPath, entryDirectory, dynamicPages, isDev,
|
|
44694
44698
|
return routes;
|
44695
44699
|
}
|
44696
44700
|
exports.getDynamicRoutes = getDynamicRoutes;
|
44697
|
-
function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes) {
|
44701
|
+
function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes, inversedAppPathRoutesManifest) {
|
44698
44702
|
return dynamicRoutes.map((route) => {
|
44699
44703
|
// i18n is already handled for middleware
|
44700
44704
|
if (route.middleware !== undefined || route.middlewarePath !== undefined)
|
@@ -44707,9 +44711,12 @@ function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, sta
|
|
44707
44711
|
const isBlocking = prerenderManifest.blockingFallbackRoutes[pathname];
|
44708
44712
|
const isApiRoute = pathnameNoPrefix === '/api' || pathnameNoPrefix?.startsWith('/api/');
|
44709
44713
|
const isAutoExport = staticPages[addLocaleOrDefault(pathname, routesManifest).substring(1)];
|
44714
|
+
const isAppRoute = inversedAppPathRoutesManifest?.[pathnameNoPrefix || ''];
|
44710
44715
|
const isLocalePrefixed = isFallback || isBlocking || isAutoExport || isServerMode;
|
44711
44716
|
route.src = route.src.replace('^', `^${dynamicPrefix ? `${dynamicPrefix}[/]?` : '[/]?'}(?${isLocalePrefixed ? '<nextLocale>' : ':'}${i18n.locales.map(locale => (0, escape_string_regexp_1.default)(locale)).join('|')})?`);
|
44712
|
-
if (isLocalePrefixed &&
|
44717
|
+
if (isLocalePrefixed &&
|
44718
|
+
!(isCorrectLocaleAPIRoutes && isApiRoute) &&
|
44719
|
+
!isAppRoute) {
|
44713
44720
|
// ensure destination has locale prefix to match prerender output
|
44714
44721
|
// path so that the prerender object is used
|
44715
44722
|
route.dest = route.dest.replace(`${path_1.default.posix.join('/', entryDirectory, '/')}`, `${path_1.default.posix.join('/', entryDirectory, '$nextLocale', '/')}`);
|
@@ -45491,7 +45498,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
|
|
45491
45498
|
exports.onPrerenderRouteInitial = onPrerenderRouteInitial;
|
45492
45499
|
let prerenderGroup = 1;
|
45493
45500
|
const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFallback, isOmitted, locale, }) => {
|
45494
|
-
const { appDir, pagesDir, static404Page, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
45501
|
+
const { appDir, pagesDir, static404Page, localePrefixed404, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
45495
45502
|
if (isBlocking && isFallback) {
|
45496
45503
|
throw new build_utils_1.NowBuildError({
|
45497
45504
|
code: 'NEXT_ISBLOCKING_ISFALLBACK',
|
@@ -45591,7 +45598,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
45591
45598
|
: // Otherwise, the route itself should exist as a static HTML
|
45592
45599
|
// file.
|
45593
45600
|
`${isOmittedOrNotFound
|
45594
|
-
?
|
45601
|
+
? localePrefixed404
|
45602
|
+
? addLocaleOrDefault('/404', routesManifest, locale)
|
45603
|
+
: '/404'
|
45595
45604
|
: routeFileNoExt}.html`),
|
45596
45605
|
});
|
45597
45606
|
}
|
@@ -45603,7 +45612,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
45603
45612
|
fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
|
45604
45613
|
? appDir
|
45605
45614
|
: pagesDir, `${isOmittedOrNotFound
|
45606
|
-
?
|
45615
|
+
? localePrefixed404
|
45616
|
+
? addLocaleOrDefault('/404.html', routesManifest, locale)
|
45617
|
+
: '/404.html'
|
45607
45618
|
: isAppPathRoute
|
45608
45619
|
? dataRoute
|
45609
45620
|
: routeFileNoExt + '.json'}`),
|
package/dist/server-build.js
CHANGED
@@ -63,15 +63,17 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
63
63
|
};
|
64
64
|
const { i18n } = routesManifest;
|
65
65
|
const hasPages404 = routesManifest.pages404;
|
66
|
+
let localePrefixed404 = false;
|
66
67
|
let static404Page = staticPages[path_1.default.posix.join(entryDirectory, '404')] && hasPages404
|
67
68
|
? path_1.default.posix.join(entryDirectory, '404')
|
68
69
|
: staticPages[path_1.default.posix.join(entryDirectory, '_errors/404')]
|
69
70
|
? path_1.default.posix.join(entryDirectory, '_errors/404')
|
70
71
|
: undefined;
|
71
72
|
if (!static404Page && i18n) {
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
if (staticPages[path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')]) {
|
74
|
+
localePrefixed404 = true;
|
75
|
+
static404Page = path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404');
|
76
|
+
}
|
75
77
|
}
|
76
78
|
if (!hasStatic500 && i18n) {
|
77
79
|
hasStatic500 =
|
@@ -560,6 +562,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
560
562
|
// this is handled in onPrerenderRoute for SSG pages
|
561
563
|
if (i18n &&
|
562
564
|
!isPrerender &&
|
565
|
+
!group.isAppRouter &&
|
563
566
|
(!isCorrectLocaleAPIRoutes ||
|
564
567
|
!(pageNoExt === 'api' || pageNoExt.startsWith('api/')))) {
|
565
568
|
for (const locale of i18n.locales) {
|
@@ -587,6 +590,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
587
590
|
isSharedLambdas: false,
|
588
591
|
canUsePreviewMode,
|
589
592
|
static404Page,
|
593
|
+
localePrefixed404,
|
590
594
|
hasPages404: routesManifest.pages404,
|
591
595
|
isCorrectNotFoundRoutes,
|
592
596
|
isEmptyAllowQueryForPrendered,
|
@@ -617,7 +621,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
|
|
617
621
|
});
|
618
622
|
const isNextDataServerResolving = middleware.staticRoutes.length > 0 &&
|
619
623
|
semver_1.default.gte(nextVersion, NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION);
|
620
|
-
const dynamicRoutes = await (0, utils_1.getDynamicRoutes)(entryPath, entryDirectory, dynamicPages, false, routesManifest, omittedPrerenderRoutes, canUsePreviewMode, prerenderManifest.bypassToken || '', true, middleware.dynamicRouteMap, inversedAppPathManifest).then(arr => (0, utils_1.localizeDynamicRoutes)(arr, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, true, isCorrectLocaleAPIRoutes));
|
624
|
+
const dynamicRoutes = await (0, utils_1.getDynamicRoutes)(entryPath, entryDirectory, dynamicPages, false, routesManifest, omittedPrerenderRoutes, canUsePreviewMode, prerenderManifest.bypassToken || '', true, middleware.dynamicRouteMap, inversedAppPathManifest).then(arr => (0, utils_1.localizeDynamicRoutes)(arr, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, true, isCorrectLocaleAPIRoutes, inversedAppPathManifest));
|
621
625
|
const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await (0, utils_1.getStaticFiles)(entryPath, entryDirectory, outputDirectory);
|
622
626
|
const normalizeNextDataRoute = (isOverride = false) => {
|
623
627
|
return isNextDataServerResolving
|
package/dist/utils.js
CHANGED
@@ -328,7 +328,7 @@ async function getDynamicRoutes(entryPath, entryDirectory, dynamicPages, isDev,
|
|
328
328
|
return routes;
|
329
329
|
}
|
330
330
|
exports.getDynamicRoutes = getDynamicRoutes;
|
331
|
-
function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes) {
|
331
|
+
function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes, inversedAppPathRoutesManifest) {
|
332
332
|
return dynamicRoutes.map((route) => {
|
333
333
|
// i18n is already handled for middleware
|
334
334
|
if (route.middleware !== undefined || route.middlewarePath !== undefined)
|
@@ -341,9 +341,12 @@ function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, sta
|
|
341
341
|
const isBlocking = prerenderManifest.blockingFallbackRoutes[pathname];
|
342
342
|
const isApiRoute = pathnameNoPrefix === '/api' || pathnameNoPrefix?.startsWith('/api/');
|
343
343
|
const isAutoExport = staticPages[addLocaleOrDefault(pathname, routesManifest).substring(1)];
|
344
|
+
const isAppRoute = inversedAppPathRoutesManifest?.[pathnameNoPrefix || ''];
|
344
345
|
const isLocalePrefixed = isFallback || isBlocking || isAutoExport || isServerMode;
|
345
346
|
route.src = route.src.replace('^', `^${dynamicPrefix ? `${dynamicPrefix}[/]?` : '[/]?'}(?${isLocalePrefixed ? '<nextLocale>' : ':'}${i18n.locales.map(locale => (0, escape_string_regexp_1.default)(locale)).join('|')})?`);
|
346
|
-
if (isLocalePrefixed &&
|
347
|
+
if (isLocalePrefixed &&
|
348
|
+
!(isCorrectLocaleAPIRoutes && isApiRoute) &&
|
349
|
+
!isAppRoute) {
|
347
350
|
// ensure destination has locale prefix to match prerender output
|
348
351
|
// path so that the prerender object is used
|
349
352
|
route.dest = route.dest.replace(`${path_1.default.posix.join('/', entryDirectory, '/')}`, `${path_1.default.posix.join('/', entryDirectory, '$nextLocale', '/')}`);
|
@@ -1125,7 +1128,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
|
|
1125
1128
|
exports.onPrerenderRouteInitial = onPrerenderRouteInitial;
|
1126
1129
|
let prerenderGroup = 1;
|
1127
1130
|
const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFallback, isOmitted, locale, }) => {
|
1128
|
-
const { appDir, pagesDir, static404Page, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
1131
|
+
const { appDir, pagesDir, static404Page, localePrefixed404, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
|
1129
1132
|
if (isBlocking && isFallback) {
|
1130
1133
|
throw new build_utils_1.NowBuildError({
|
1131
1134
|
code: 'NEXT_ISBLOCKING_ISFALLBACK',
|
@@ -1225,7 +1228,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1225
1228
|
: // Otherwise, the route itself should exist as a static HTML
|
1226
1229
|
// file.
|
1227
1230
|
`${isOmittedOrNotFound
|
1228
|
-
?
|
1231
|
+
? localePrefixed404
|
1232
|
+
? addLocaleOrDefault('/404', routesManifest, locale)
|
1233
|
+
: '/404'
|
1229
1234
|
: routeFileNoExt}.html`),
|
1230
1235
|
});
|
1231
1236
|
}
|
@@ -1237,7 +1242,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
|
|
1237
1242
|
fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
|
1238
1243
|
? appDir
|
1239
1244
|
: pagesDir, `${isOmittedOrNotFound
|
1240
|
-
?
|
1245
|
+
? localePrefixed404
|
1246
|
+
? addLocaleOrDefault('/404.html', routesManifest, locale)
|
1247
|
+
: '/404.html'
|
1241
1248
|
: isAppPathRoute
|
1242
1249
|
? dataRoute
|
1243
1250
|
: routeFileNoExt + '.json'}`),
|