@vercel/next 3.9.0 → 3.9.2

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 CHANGED
@@ -41588,7 +41588,8 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41588
41588
  appPathRoutesManifest,
41589
41589
  });
41590
41590
  const canUsePreviewMode = Object.keys(pages).some(page => (0, utils_1.isApiPage)(pages[page].fsPath));
41591
- staticPages = await (0, utils_1.filterStaticPages)(await (0, build_utils_1.glob)('**/*.html', pagesDir), dynamicPages, entryDirectory, exports.htmlContentType, prerenderManifest, routesManifest);
41591
+ const originalStaticPages = await (0, build_utils_1.glob)('**/*.html', pagesDir);
41592
+ staticPages = await (0, utils_1.filterStaticPages)(originalStaticPages, dynamicPages, entryDirectory, exports.htmlContentType, prerenderManifest, routesManifest);
41592
41593
  hasStatic500 = !!staticPages[path_1.default.posix.join(entryDirectory, '500')];
41593
41594
  // this can be either 404.html in latest versions
41594
41595
  // or _errors/404.html versions while this was experimental
@@ -41708,6 +41709,8 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41708
41709
  if (!routesManifest) {
41709
41710
  throw new Error(`A routes-manifest could not be located, please check your outputDirectory and try again.`);
41710
41711
  }
41712
+ const localePrefixed404 = !!(routesManifest.i18n &&
41713
+ originalStaticPages[path_1.default.posix.join(entryDirectory, routesManifest.i18n.defaultLocale, '404.html')]);
41711
41714
  return (0, server_build_1.serverBuild)({
41712
41715
  config,
41713
41716
  functionsConfigManifest,
@@ -41717,6 +41720,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41717
41720
  dynamicPages,
41718
41721
  canUsePreviewMode,
41719
41722
  staticPages,
41723
+ localePrefixed404,
41720
41724
  lambdaPages: pages,
41721
41725
  lambdaAppPaths,
41722
41726
  omittedPrerenderRoutes,
@@ -43103,7 +43107,7 @@ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
43103
43107
  const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
43104
43108
  const EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = 'v12.2.0';
43105
43109
  const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
43106
- async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfigManifest, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, hasIsr500Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, lambdaAppPaths, canUsePreviewMode, trailingSlash, prerenderManifest, appPathRoutesManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
43110
+ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfigManifest, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, hasIsr500Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, localePrefixed404, nextVersion, lambdaAppPaths, canUsePreviewMode, trailingSlash, prerenderManifest, appPathRoutesManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
43107
43111
  lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
43108
43112
  const lambdas = {};
43109
43113
  const prerenders = {};
@@ -43150,10 +43154,10 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
43150
43154
  : staticPages[path_1.default.posix.join(entryDirectory, '_errors/404')]
43151
43155
  ? path_1.default.posix.join(entryDirectory, '_errors/404')
43152
43156
  : undefined;
43153
- if (!static404Page && i18n) {
43154
- static404Page = staticPages[path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')]
43155
- ? path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')
43156
- : undefined;
43157
+ if (!static404Page &&
43158
+ i18n &&
43159
+ staticPages[path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')]) {
43160
+ static404Page = path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404');
43157
43161
  }
43158
43162
  if (!hasStatic500 && i18n) {
43159
43163
  hasStatic500 =
@@ -43642,6 +43646,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
43642
43646
  // this is handled in onPrerenderRoute for SSG pages
43643
43647
  if (i18n &&
43644
43648
  !isPrerender &&
43649
+ !group.isAppRouter &&
43645
43650
  (!isCorrectLocaleAPIRoutes ||
43646
43651
  !(pageNoExt === 'api' || pageNoExt.startsWith('api/')))) {
43647
43652
  for (const locale of i18n.locales) {
@@ -43669,6 +43674,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
43669
43674
  isSharedLambdas: false,
43670
43675
  canUsePreviewMode,
43671
43676
  static404Page,
43677
+ localePrefixed404,
43672
43678
  hasPages404: routesManifest.pages404,
43673
43679
  isCorrectNotFoundRoutes,
43674
43680
  isEmptyAllowQueryForPrendered,
@@ -43699,7 +43705,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
43699
43705
  });
43700
43706
  const isNextDataServerResolving = middleware.staticRoutes.length > 0 &&
43701
43707
  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));
43708
+ 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
43709
  const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await (0, utils_1.getStaticFiles)(entryPath, entryDirectory, outputDirectory);
43704
43710
  const normalizeNextDataRoute = (isOverride = false) => {
43705
43711
  return isNextDataServerResolving
@@ -44694,7 +44700,7 @@ async function getDynamicRoutes(entryPath, entryDirectory, dynamicPages, isDev,
44694
44700
  return routes;
44695
44701
  }
44696
44702
  exports.getDynamicRoutes = getDynamicRoutes;
44697
- function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes) {
44703
+ function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, isServerMode, isCorrectLocaleAPIRoutes, inversedAppPathRoutesManifest) {
44698
44704
  return dynamicRoutes.map((route) => {
44699
44705
  // i18n is already handled for middleware
44700
44706
  if (route.middleware !== undefined || route.middlewarePath !== undefined)
@@ -44707,9 +44713,12 @@ function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, sta
44707
44713
  const isBlocking = prerenderManifest.blockingFallbackRoutes[pathname];
44708
44714
  const isApiRoute = pathnameNoPrefix === '/api' || pathnameNoPrefix?.startsWith('/api/');
44709
44715
  const isAutoExport = staticPages[addLocaleOrDefault(pathname, routesManifest).substring(1)];
44716
+ const isAppRoute = inversedAppPathRoutesManifest?.[pathnameNoPrefix || ''];
44710
44717
  const isLocalePrefixed = isFallback || isBlocking || isAutoExport || isServerMode;
44711
44718
  route.src = route.src.replace('^', `^${dynamicPrefix ? `${dynamicPrefix}[/]?` : '[/]?'}(?${isLocalePrefixed ? '<nextLocale>' : ':'}${i18n.locales.map(locale => (0, escape_string_regexp_1.default)(locale)).join('|')})?`);
44712
- if (isLocalePrefixed && !(isCorrectLocaleAPIRoutes && isApiRoute)) {
44719
+ if (isLocalePrefixed &&
44720
+ !(isCorrectLocaleAPIRoutes && isApiRoute) &&
44721
+ !isAppRoute) {
44713
44722
  // ensure destination has locale prefix to match prerender output
44714
44723
  // path so that the prerender object is used
44715
44724
  route.dest = route.dest.replace(`${path_1.default.posix.join('/', entryDirectory, '/')}`, `${path_1.default.posix.join('/', entryDirectory, '$nextLocale', '/')}`);
@@ -45491,7 +45500,7 @@ const onPrerenderRouteInitial = (prerenderManifest, canUsePreviewMode, entryDire
45491
45500
  exports.onPrerenderRouteInitial = onPrerenderRouteInitial;
45492
45501
  let prerenderGroup = 1;
45493
45502
  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;
45503
+ const { appDir, pagesDir, static404Page, localePrefixed404, entryDirectory, prerenderManifest, isSharedLambdas, isServerMode, canUsePreviewMode, lambdas, prerenders, pageLambdaMap, routesManifest, isCorrectNotFoundRoutes, isEmptyAllowQueryForPrendered, } = prerenderRouteArgs;
45495
45504
  if (isBlocking && isFallback) {
45496
45505
  throw new build_utils_1.NowBuildError({
45497
45506
  code: 'NEXT_ISBLOCKING_ISFALLBACK',
@@ -45591,7 +45600,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
45591
45600
  : // Otherwise, the route itself should exist as a static HTML
45592
45601
  // file.
45593
45602
  `${isOmittedOrNotFound
45594
- ? addLocaleOrDefault('/404', routesManifest, locale)
45603
+ ? localePrefixed404
45604
+ ? addLocaleOrDefault('/404', routesManifest, locale)
45605
+ : '/404'
45595
45606
  : routeFileNoExt}.html`),
45596
45607
  });
45597
45608
  }
@@ -45603,7 +45614,9 @@ const onPrerenderRoute = (prerenderRouteArgs) => (routeKey, { isBlocking, isFall
45603
45614
  fsPath: path_1.default.join(isAppPathRoute && !isOmittedOrNotFound && appDir
45604
45615
  ? appDir
45605
45616
  : pagesDir, `${isOmittedOrNotFound
45606
- ? addLocaleOrDefault('/404.html', routesManifest, locale)
45617
+ ? localePrefixed404
45618
+ ? addLocaleOrDefault('/404.html', routesManifest, locale)
45619
+ : '/404.html'
45607
45620
  : isAppPathRoute
45608
45621
  ? dataRoute
45609
45622
  : routeFileNoExt + '.json'}`),
@@ -21,7 +21,7 @@ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
21
21
  const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
22
22
  const EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = 'v12.2.0';
23
23
  const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
24
- async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfigManifest, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, hasIsr500Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, lambdaAppPaths, canUsePreviewMode, trailingSlash, prerenderManifest, appPathRoutesManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
24
+ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfigManifest, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, hasIsr500Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, localePrefixed404, nextVersion, lambdaAppPaths, canUsePreviewMode, trailingSlash, prerenderManifest, appPathRoutesManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
25
25
  lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
26
26
  const lambdas = {};
27
27
  const prerenders = {};
@@ -68,10 +68,10 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
68
68
  : staticPages[path_1.default.posix.join(entryDirectory, '_errors/404')]
69
69
  ? path_1.default.posix.join(entryDirectory, '_errors/404')
70
70
  : undefined;
71
- if (!static404Page && i18n) {
72
- static404Page = staticPages[path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')]
73
- ? path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')
74
- : undefined;
71
+ if (!static404Page &&
72
+ i18n &&
73
+ staticPages[path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404')]) {
74
+ static404Page = path_1.default.posix.join(entryDirectory, i18n.defaultLocale, '404');
75
75
  }
76
76
  if (!hasStatic500 && i18n) {
77
77
  hasStatic500 =
@@ -560,6 +560,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
560
560
  // this is handled in onPrerenderRoute for SSG pages
561
561
  if (i18n &&
562
562
  !isPrerender &&
563
+ !group.isAppRouter &&
563
564
  (!isCorrectLocaleAPIRoutes ||
564
565
  !(pageNoExt === 'api' || pageNoExt.startsWith('api/')))) {
565
566
  for (const locale of i18n.locales) {
@@ -587,6 +588,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
587
588
  isSharedLambdas: false,
588
589
  canUsePreviewMode,
589
590
  static404Page,
591
+ localePrefixed404,
590
592
  hasPages404: routesManifest.pages404,
591
593
  isCorrectNotFoundRoutes,
592
594
  isEmptyAllowQueryForPrendered,
@@ -617,7 +619,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, functionsConfi
617
619
  });
618
620
  const isNextDataServerResolving = middleware.staticRoutes.length > 0 &&
619
621
  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));
622
+ 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
623
  const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await (0, utils_1.getStaticFiles)(entryPath, entryDirectory, outputDirectory);
622
624
  const normalizeNextDataRoute = (isOverride = false) => {
623
625
  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 && !(isCorrectLocaleAPIRoutes && isApiRoute)) {
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
- ? addLocaleOrDefault('/404', routesManifest, locale)
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
- ? addLocaleOrDefault('/404.html', routesManifest, locale)
1245
+ ? localePrefixed404
1246
+ ? addLocaleOrDefault('/404.html', routesManifest, locale)
1247
+ : '/404.html'
1241
1248
  : isAppPathRoute
1242
1249
  ? dataRoute
1243
1250
  : routeFileNoExt + '.json'}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.9.0",
3
+ "version": "3.9.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",