@vercel/next 3.8.7 → 3.9.0

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
@@ -40971,7 +40971,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
40971
40971
  cwd: entryPath,
40972
40972
  });
40973
40973
  let hasLegacyRoutes = false;
40974
- const hasFunctionsConfig = !!config.functions;
40974
+ const hasFunctionsConfig = Boolean(config.functions);
40975
40975
  if (await (0, fs_extra_1.pathExists)(dotNextStatic)) {
40976
40976
  console.warn('WARNING: You should not upload the `.next` directory.');
40977
40977
  }
@@ -41137,7 +41137,8 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41137
41137
  const requiredServerFilesManifest = isServerMode
41138
41138
  ? await (0, utils_1.getRequiredServerFilesManifest)(entryPath, outputDirectory)
41139
41139
  : false;
41140
- isServerMode = !!requiredServerFilesManifest;
41140
+ isServerMode = Boolean(requiredServerFilesManifest);
41141
+ const functionsConfigManifest = await (0, utils_1.getFunctionsConfigManifest)(entryPath, outputDirectory);
41141
41142
  const routesManifest = await (0, utils_1.getRoutesManifest)(entryPath, outputDirectory, nextVersion);
41142
41143
  const imagesManifest = await (0, utils_1.getImagesManifest)(entryPath, outputDirectory);
41143
41144
  const prerenderManifest = await (0, utils_1.getPrerenderManifest)(entryPath, outputDirectory);
@@ -41709,6 +41710,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41709
41710
  }
41710
41711
  return (0, server_build_1.serverBuild)({
41711
41712
  config,
41713
+ functionsConfigManifest,
41712
41714
  nextVersion,
41713
41715
  trailingSlash,
41714
41716
  appPathRoutesManifest,
@@ -41876,6 +41878,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41876
41878
  const initialPageLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
41877
41879
  entryPath,
41878
41880
  config,
41881
+ functionsConfigManifest,
41879
41882
  pages: nonApiPages,
41880
41883
  prerenderRoutes: new Set(),
41881
41884
  pageTraces,
@@ -41891,6 +41894,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41891
41894
  const initialApiLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
41892
41895
  entryPath,
41893
41896
  config,
41897
+ functionsConfigManifest,
41894
41898
  pages: apiPages,
41895
41899
  prerenderRoutes: new Set(),
41896
41900
  pageTraces,
@@ -43099,7 +43103,7 @@ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
43099
43103
  const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
43100
43104
  const EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = 'v12.2.0';
43101
43105
  const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
43102
- async function serverBuild({ dynamicPages, pagesDir, config = {}, 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, }) {
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, }) {
43103
43107
  lambdaPages = Object.assign({}, lambdaPages, lambdaAppPaths);
43104
43108
  const lambdas = {};
43105
43109
  const prerenders = {};
@@ -43473,6 +43477,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43473
43477
  const pageLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
43474
43478
  entryPath: projectDir,
43475
43479
  config,
43480
+ functionsConfigManifest,
43476
43481
  pages: nonApiPages,
43477
43482
  prerenderRoutes,
43478
43483
  pageTraces,
@@ -43487,6 +43492,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43487
43492
  const appRouterLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
43488
43493
  entryPath: projectDir,
43489
43494
  config,
43495
+ functionsConfigManifest,
43490
43496
  pages: appRouterPages,
43491
43497
  prerenderRoutes,
43492
43498
  pageTraces,
@@ -43507,6 +43513,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43507
43513
  const apiLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
43508
43514
  entryPath: projectDir,
43509
43515
  config,
43516
+ functionsConfigManifest,
43510
43517
  pages: apiPages,
43511
43518
  prerenderRoutes,
43512
43519
  pageTraces,
@@ -43778,7 +43785,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43778
43785
  if (ogRoute.endsWith('/route')) {
43779
43786
  continue;
43780
43787
  }
43781
- route = path_1.default.posix.join('./', route === '/' ? '/index' : route);
43788
+ route = path_1.default.posix.join('./', entryDirectory, route === '/' ? '/index' : route);
43782
43789
  if (lambdas[route]) {
43783
43790
  lambdas[`${route}.rsc`] = lambdas[route];
43784
43791
  }
@@ -43790,6 +43797,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43790
43797
  const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
43791
43798
  const rscVaryHeader = routesManifest?.rsc?.varyHeader ||
43792
43799
  'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
43800
+ const appNotFoundPath = path_1.default.posix.join('.', entryDirectory, '_not-found');
43793
43801
  return {
43794
43802
  wildcard: wildcardConfig,
43795
43803
  images: (0, utils_1.getImagesConfig)(imagesManifest),
@@ -44210,7 +44218,11 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
44210
44218
  hasIsr404Page ||
44211
44219
  lambdas[path_1.default.posix.join(entryDirectory, '404')]
44212
44220
  ? '/404'
44213
- : '/_error'),
44221
+ : appPathRoutesManifest &&
44222
+ (middleware.edgeFunctions[appNotFoundPath] ||
44223
+ lambdas[appNotFoundPath])
44224
+ ? '/_not-found'
44225
+ : '/_error'),
44214
44226
  status: 404,
44215
44227
  },
44216
44228
  ]),
@@ -44380,7 +44392,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44380
44392
  return (mod && mod.__esModule) ? mod : { "default": mod };
44381
44393
  };
44382
44394
  Object.defineProperty(exports, "__esModule", ({ value: true }));
44383
- 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;
44395
+ exports.isApiPage = exports.getOperationType = exports.upgradeMiddlewareManifest = exports.getMiddlewareManifest = exports.getFunctionsConfigManifest = 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;
44384
44396
  const build_utils_1 = __webpack_require__(3445);
44385
44397
  const async_sema_1 = __webpack_require__(7905);
44386
44398
  const buffer_crc32_1 = __importDefault(__webpack_require__(2227));
@@ -45224,23 +45236,28 @@ exports.addLocaleOrDefault = addLocaleOrDefault;
45224
45236
  exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * exports.MIB;
45225
45237
  const LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 2.5 * exports.MIB;
45226
45238
  const LAMBDA_RESERVED_COMPRESSED_SIZE = 250 * exports.KIB;
45227
- async function getPageLambdaGroups({ entryPath, config, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer, initialPseudoLayer, initialPseudoLayerUncompressed, lambdaCompressedByteLimit, internalPages, pageExtensions, }) {
45239
+ async function getPageLambdaGroups({ entryPath, config, functionsConfigManifest, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer, initialPseudoLayer, initialPseudoLayerUncompressed, lambdaCompressedByteLimit, internalPages, pageExtensions, }) {
45228
45240
  const groups = [];
45229
45241
  for (const page of pages) {
45230
45242
  const newPages = [...internalPages, page];
45231
45243
  const routeName = normalizePage(page.replace(/\.js$/, ''));
45232
45244
  const isPrerenderRoute = prerenderRoutes.has(routeName);
45233
45245
  let opts = {};
45246
+ if (functionsConfigManifest &&
45247
+ functionsConfigManifest.functions[routeName]) {
45248
+ opts = functionsConfigManifest.functions[routeName];
45249
+ }
45234
45250
  if (config && config.functions) {
45235
45251
  const sourceFile = await getSourceFilePathFromPage({
45236
45252
  workPath: entryPath,
45237
45253
  page,
45238
45254
  pageExtensions,
45239
45255
  });
45240
- opts = await (0, build_utils_1.getLambdaOptionsFromFunction)({
45256
+ const vercelConfigOpts = await (0, build_utils_1.getLambdaOptionsFromFunction)({
45241
45257
  sourceFile,
45242
45258
  config,
45243
45259
  });
45260
+ opts = { ...vercelConfigOpts, ...opts };
45244
45261
  }
45245
45262
  let matchingGroup = groups.find(group => {
45246
45263
  const matches = group.maxDuration === opts.maxDuration &&
@@ -46053,7 +46070,9 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
46053
46070
  shortPath = shortPath.replace(/^pages\//, '');
46054
46071
  }
46055
46072
  else if (shortPath.startsWith('app/') &&
46056
- (shortPath.endsWith('/page') || shortPath.endsWith('/route'))) {
46073
+ (shortPath.endsWith('/page') ||
46074
+ shortPath.endsWith('/route') ||
46075
+ shortPath === 'app/_not-found')) {
46057
46076
  const ogRoute = shortPath.replace(/^app\//, '/');
46058
46077
  shortPath = (appPathRoutesManifest[ogRoute] ||
46059
46078
  shortPath.replace(/(^|\/)(page|route)$/, '')).replace(/^\//, '');
@@ -46111,6 +46130,24 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
46111
46130
  };
46112
46131
  }
46113
46132
  exports.getMiddlewareBundle = getMiddlewareBundle;
46133
+ /**
46134
+ * Attempts to read the functions config manifest from the pre-defined
46135
+ * location. If the manifest can't be found it will resolve to
46136
+ * undefined.
46137
+ */
46138
+ async function getFunctionsConfigManifest(entryPath, outputDirectory) {
46139
+ const functionConfigManifestPath = path_1.default.join(entryPath, outputDirectory, './server/functions-config-manifest.json');
46140
+ const hasManifest = await fs_extra_1.default
46141
+ .access(functionConfigManifestPath)
46142
+ .then(() => true)
46143
+ .catch(() => false);
46144
+ if (!hasManifest) {
46145
+ return;
46146
+ }
46147
+ const manifest = await fs_extra_1.default.readJSON(functionConfigManifestPath);
46148
+ return manifest.version === 1 ? manifest : undefined;
46149
+ }
46150
+ exports.getFunctionsConfigManifest = getFunctionsConfigManifest;
46114
46151
  /**
46115
46152
  * Attempts to read the middleware manifest from the pre-defined
46116
46153
  * location. If the manifest can't be found it will resolve to
@@ -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 = {}, 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, 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 = {};
@@ -395,6 +395,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
395
395
  const pageLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
396
396
  entryPath: projectDir,
397
397
  config,
398
+ functionsConfigManifest,
398
399
  pages: nonApiPages,
399
400
  prerenderRoutes,
400
401
  pageTraces,
@@ -409,6 +410,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
409
410
  const appRouterLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
410
411
  entryPath: projectDir,
411
412
  config,
413
+ functionsConfigManifest,
412
414
  pages: appRouterPages,
413
415
  prerenderRoutes,
414
416
  pageTraces,
@@ -429,6 +431,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
429
431
  const apiLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
430
432
  entryPath: projectDir,
431
433
  config,
434
+ functionsConfigManifest,
432
435
  pages: apiPages,
433
436
  prerenderRoutes,
434
437
  pageTraces,
@@ -700,7 +703,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
700
703
  if (ogRoute.endsWith('/route')) {
701
704
  continue;
702
705
  }
703
- route = path_1.default.posix.join('./', route === '/' ? '/index' : route);
706
+ route = path_1.default.posix.join('./', entryDirectory, route === '/' ? '/index' : route);
704
707
  if (lambdas[route]) {
705
708
  lambdas[`${route}.rsc`] = lambdas[route];
706
709
  }
@@ -712,6 +715,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
712
715
  const rscHeader = routesManifest.rsc?.header?.toLowerCase() || '__rsc__';
713
716
  const rscVaryHeader = routesManifest?.rsc?.varyHeader ||
714
717
  'RSC, Next-Router-State-Tree, Next-Router-Prefetch';
718
+ const appNotFoundPath = path_1.default.posix.join('.', entryDirectory, '_not-found');
715
719
  return {
716
720
  wildcard: wildcardConfig,
717
721
  images: (0, utils_1.getImagesConfig)(imagesManifest),
@@ -1132,7 +1136,11 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
1132
1136
  hasIsr404Page ||
1133
1137
  lambdas[path_1.default.posix.join(entryDirectory, '404')]
1134
1138
  ? '/404'
1135
- : '/_error'),
1139
+ : appPathRoutesManifest &&
1140
+ (middleware.edgeFunctions[appNotFoundPath] ||
1141
+ lambdas[appNotFoundPath])
1142
+ ? '/_not-found'
1143
+ : '/_error'),
1136
1144
  status: 404,
1137
1145
  },
1138
1146
  ]),
package/dist/utils.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- 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;
29
+ exports.isApiPage = exports.getOperationType = exports.upgradeMiddlewareManifest = exports.getMiddlewareManifest = exports.getFunctionsConfigManifest = 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;
30
30
  const build_utils_1 = require("@vercel/build-utils");
31
31
  const async_sema_1 = require("async-sema");
32
32
  const buffer_crc32_1 = __importDefault(require("buffer-crc32"));
@@ -870,23 +870,28 @@ exports.addLocaleOrDefault = addLocaleOrDefault;
870
870
  exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * exports.MIB;
871
871
  const LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 2.5 * exports.MIB;
872
872
  const LAMBDA_RESERVED_COMPRESSED_SIZE = 250 * exports.KIB;
873
- async function getPageLambdaGroups({ entryPath, config, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer, initialPseudoLayer, initialPseudoLayerUncompressed, lambdaCompressedByteLimit, internalPages, pageExtensions, }) {
873
+ async function getPageLambdaGroups({ entryPath, config, functionsConfigManifest, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer, initialPseudoLayer, initialPseudoLayerUncompressed, lambdaCompressedByteLimit, internalPages, pageExtensions, }) {
874
874
  const groups = [];
875
875
  for (const page of pages) {
876
876
  const newPages = [...internalPages, page];
877
877
  const routeName = normalizePage(page.replace(/\.js$/, ''));
878
878
  const isPrerenderRoute = prerenderRoutes.has(routeName);
879
879
  let opts = {};
880
+ if (functionsConfigManifest &&
881
+ functionsConfigManifest.functions[routeName]) {
882
+ opts = functionsConfigManifest.functions[routeName];
883
+ }
880
884
  if (config && config.functions) {
881
885
  const sourceFile = await getSourceFilePathFromPage({
882
886
  workPath: entryPath,
883
887
  page,
884
888
  pageExtensions,
885
889
  });
886
- opts = await (0, build_utils_1.getLambdaOptionsFromFunction)({
890
+ const vercelConfigOpts = await (0, build_utils_1.getLambdaOptionsFromFunction)({
887
891
  sourceFile,
888
892
  config,
889
893
  });
894
+ opts = { ...vercelConfigOpts, ...opts };
890
895
  }
891
896
  let matchingGroup = groups.find(group => {
892
897
  const matches = group.maxDuration === opts.maxDuration &&
@@ -1699,7 +1704,9 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1699
1704
  shortPath = shortPath.replace(/^pages\//, '');
1700
1705
  }
1701
1706
  else if (shortPath.startsWith('app/') &&
1702
- (shortPath.endsWith('/page') || shortPath.endsWith('/route'))) {
1707
+ (shortPath.endsWith('/page') ||
1708
+ shortPath.endsWith('/route') ||
1709
+ shortPath === 'app/_not-found')) {
1703
1710
  const ogRoute = shortPath.replace(/^app\//, '/');
1704
1711
  shortPath = (appPathRoutesManifest[ogRoute] ||
1705
1712
  shortPath.replace(/(^|\/)(page|route)$/, '')).replace(/^\//, '');
@@ -1757,6 +1764,24 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1757
1764
  };
1758
1765
  }
1759
1766
  exports.getMiddlewareBundle = getMiddlewareBundle;
1767
+ /**
1768
+ * Attempts to read the functions config manifest from the pre-defined
1769
+ * location. If the manifest can't be found it will resolve to
1770
+ * undefined.
1771
+ */
1772
+ async function getFunctionsConfigManifest(entryPath, outputDirectory) {
1773
+ const functionConfigManifestPath = path_1.default.join(entryPath, outputDirectory, './server/functions-config-manifest.json');
1774
+ const hasManifest = await fs_extra_1.default
1775
+ .access(functionConfigManifestPath)
1776
+ .then(() => true)
1777
+ .catch(() => false);
1778
+ if (!hasManifest) {
1779
+ return;
1780
+ }
1781
+ const manifest = await fs_extra_1.default.readJSON(functionConfigManifestPath);
1782
+ return manifest.version === 1 ? manifest : undefined;
1783
+ }
1784
+ exports.getFunctionsConfigManifest = getFunctionsConfigManifest;
1760
1785
  /**
1761
1786
  * Attempts to read the middleware manifest from the pre-defined
1762
1787
  * location. If the manifest can't be found it will resolve to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.8.7",
3
+ "version": "3.9.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -26,7 +26,7 @@
26
26
  "@types/semver": "6.0.0",
27
27
  "@types/text-table": "0.2.1",
28
28
  "@types/webpack-sources": "3.2.0",
29
- "@vercel/build-utils": "6.8.0",
29
+ "@vercel/build-utils": "6.8.2",
30
30
  "@vercel/nft": "0.22.5",
31
31
  "@vercel/routing-utils": "2.2.1",
32
32
  "async-sema": "3.0.1",