@vercel/next 3.1.7 → 3.1.10

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.
@@ -20,6 +20,7 @@ const CORRECT_NOT_FOUND_ROUTES_VERSION = 'v12.0.1';
20
20
  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
+ const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
23
24
  async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, trailingSlash, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
24
25
  const lambdas = {};
25
26
  const prerenders = {};
@@ -29,6 +30,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
29
30
  const isEmptyAllowQueryForPrendered = semver_1.default.gte(nextVersion, EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION);
30
31
  const isCorrectNotFoundRoutes = semver_1.default.gte(nextVersion, CORRECT_NOT_FOUND_ROUTES_VERSION);
31
32
  const isCorrectMiddlewareOrder = semver_1.default.gte(nextVersion, CORRECT_MIDDLEWARE_ORDER_VERSION);
33
+ const isCorrectManifests = semver_1.default.gte(nextVersion, CORRECTED_MANIFESTS_VERSION);
32
34
  let hasStatic500 = !!staticPages[path_1.default.join(entryDirectory, '500')];
33
35
  if (lambdaPageKeys.length === 0) {
34
36
  throw new build_utils_1.NowBuildError({
@@ -207,7 +209,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
207
209
  if (requiredServerFilesManifest.appDir) {
208
210
  fsPath = path_1.default.join(requiredServerFilesManifest.appDir, file);
209
211
  }
210
- const relativePath = path_1.default.join(path_1.default.relative(baseDir, fsPath));
212
+ const relativePath = path_1.default.relative(baseDir, fsPath);
211
213
  const { mode } = await fs_extra_1.default.lstat(fsPath);
212
214
  lstatSema.release();
213
215
  requiredFiles[relativePath] = new build_utils_1.FileFsRef({
@@ -363,16 +365,67 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
363
365
  const combinedGroups = [...pageLambdaGroups, ...apiLambdaGroups];
364
366
  await (0, utils_1.detectLambdaLimitExceeding)(combinedGroups, lambdaCompressedByteLimit, compressedPages);
365
367
  for (const group of combinedGroups) {
368
+ const groupPageFiles = {};
369
+ for (const page of [...group.pages, ...internalPages]) {
370
+ const pageFileName = path_1.default.normalize(path_1.default.relative(baseDir, lambdaPages[page].fsPath));
371
+ groupPageFiles[pageFileName] = compressedPages[page];
372
+ }
373
+ const updatedManifestFiles = {};
374
+ if (isCorrectManifests) {
375
+ // filter dynamic routes to only the included dynamic routes
376
+ // in this specific serverless function so that we don't
377
+ // accidentally match a dynamic route while resolving that
378
+ // is not actually in this specific serverless function
379
+ for (const manifest of [
380
+ 'routes-manifest.json',
381
+ 'server/pages-manifest.json',
382
+ ]) {
383
+ const fsPath = path_1.default.join(entryPath, outputDirectory, manifest);
384
+ const relativePath = path_1.default.relative(baseDir, fsPath);
385
+ delete group.pseudoLayer[relativePath];
386
+ const manifestData = await fs_extra_1.default.readJSON(fsPath);
387
+ const normalizedPages = new Set(group.pages.map(page => {
388
+ page = `/${page.replace(/\.js$/, '')}`;
389
+ if (page === '/index')
390
+ page = '/';
391
+ return page;
392
+ }));
393
+ switch (manifest) {
394
+ case 'routes-manifest.json': {
395
+ const filterItem = (item) => normalizedPages.has(item.page);
396
+ manifestData.dynamicRoutes =
397
+ manifestData.dynamicRoutes?.filter(filterItem);
398
+ manifestData.staticRoutes =
399
+ manifestData.staticRoutes?.filter(filterItem);
400
+ break;
401
+ }
402
+ case 'server/pages-manifest.json': {
403
+ for (const key of Object.keys(manifestData)) {
404
+ if ((0, utils_1.isDynamicRoute)(key) && !normalizedPages.has(key)) {
405
+ delete manifestData[key];
406
+ }
407
+ }
408
+ break;
409
+ }
410
+ default: {
411
+ throw new build_utils_1.NowBuildError({
412
+ message: `Unexpected manifest value ${manifest}, please contact support if this continues`,
413
+ code: 'NEXT_MANIFEST_INVARIANT',
414
+ });
415
+ }
416
+ }
417
+ updatedManifestFiles[relativePath] = new build_utils_1.FileBlob({
418
+ contentType: 'application/json',
419
+ data: JSON.stringify(manifestData),
420
+ });
421
+ }
422
+ }
366
423
  const lambda = await (0, utils_1.createLambdaFromPseudoLayers)({
367
- files: launcherFiles,
368
- layers: [
369
- group.pseudoLayer,
370
- [...group.pages, ...internalPages].reduce((prev, page) => {
371
- const pageFileName = path_1.default.normalize(path_1.default.relative(baseDir, lambdaPages[page].fsPath));
372
- prev[pageFileName] = compressedPages[page];
373
- return prev;
374
- }, {}),
375
- ],
424
+ files: {
425
+ ...launcherFiles,
426
+ ...updatedManifestFiles,
427
+ },
428
+ layers: [group.pseudoLayer, groupPageFiles],
376
429
  handler: path_1.default.join(path_1.default.relative(baseDir, requiredServerFilesManifest.appDir || entryPath), '___next_launcher.cjs'),
377
430
  memory: group.memory,
378
431
  runtime: nodeVersion.runtime,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.1.7",
3
+ "version": "3.1.10",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -45,8 +45,8 @@
45
45
  "@types/semver": "6.0.0",
46
46
  "@types/text-table": "0.2.1",
47
47
  "@types/webpack-sources": "3.2.0",
48
- "@vercel/build-utils": "5.0.3",
49
- "@vercel/nft": "0.20.1",
48
+ "@vercel/build-utils": "5.0.6",
49
+ "@vercel/nft": "0.21.0",
50
50
  "@vercel/routing-utils": "2.0.0",
51
51
  "async-sema": "3.0.1",
52
52
  "buffer-crc32": "0.2.13",
@@ -70,5 +70,5 @@
70
70
  "typescript": "4.5.2",
71
71
  "webpack-sources": "3.2.3"
72
72
  },
73
- "gitHead": "bef1aec76609ae661f084dcc391edd66f891f0b4"
73
+ "gitHead": "90c18959498cfa852bc56adffcdd16a8bbcbcce6"
74
74
  }