@vercel/next 2.8.67-canary.0 → 2.8.67-canary.3

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.
@@ -450,7 +450,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
450
450
  currentRouteSrc = starterRouteSrc;
451
451
  }
452
452
  // add to existing route src if src length limit isn't reached
453
- currentRouteSrc = `${currentRouteSrc.substr(0, currentRouteSrc.length - 1)}${currentRouteSrc[currentRouteSrc.length - 2] === '(' ? '' : '|'}${route})`;
453
+ currentRouteSrc = `${currentRouteSrc.substring(0, currentRouteSrc.length - 1)}${currentRouteSrc[currentRouteSrc.length - 2] === '(' ? '' : '|'}${route})`;
454
454
  if (isLastRoute) {
455
455
  pushRoute(currentRouteSrc);
456
456
  }
@@ -458,7 +458,6 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
458
458
  }
459
459
  }
460
460
  return {
461
- middleware: middleware.middleware,
462
461
  wildcard: wildcardConfig,
463
462
  images: ((_d = imagesManifest === null || imagesManifest === void 0 ? void 0 : imagesManifest.images) === null || _d === void 0 ? void 0 : _d.loader) === 'default'
464
463
  ? {
@@ -786,8 +785,6 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
786
785
  },
787
786
  ]),
788
787
  ],
789
- watch: [],
790
- childProcesses: [],
791
788
  };
792
789
  }
793
790
  exports.serverBuild = serverBuild;
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.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = 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 = void 0;
25
+ exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = 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 = 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"));
@@ -306,7 +306,7 @@ function localizeDynamicRoutes(dynamicRoutes, dynamicPrefix, entryDirectory, sta
306
306
  const isFallback = prerenderManifest.fallbackRoutes[pathname];
307
307
  const isBlocking = prerenderManifest.blockingFallbackRoutes[pathname];
308
308
  const isApiRoute = pathnameNoPrefix === '/api' || (pathnameNoPrefix === null || pathnameNoPrefix === void 0 ? void 0 : pathnameNoPrefix.startsWith('/api/'));
309
- const isAutoExport = staticPages[addLocaleOrDefault(pathname, routesManifest).substr(1)];
309
+ const isAutoExport = staticPages[addLocaleOrDefault(pathname, routesManifest).substring(1)];
310
310
  const isLocalePrefixed = isFallback || isBlocking || isAutoExport || isServerMode;
311
311
  route.src = route.src.replace('^', `^${dynamicPrefix ? `${dynamicPrefix}[/]?` : '[/]?'}(?${isLocalePrefixed ? '<nextLocale>' : ':'}${i18n.locales.map(locale => (0, escape_string_regexp_1.default)(locale)).join('|')})?`);
312
312
  if (isLocalePrefixed && !(isCorrectLocaleAPIRoutes && isApiRoute)) {
@@ -1340,27 +1340,44 @@ async function getPrivateOutputs(dir, entries) {
1340
1340
  }
1341
1341
  exports.getPrivateOutputs = getPrivateOutputs;
1342
1342
  async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, }) {
1343
+ var _a;
1343
1344
  const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
1344
- if (middlewareManifest && (middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.sortedMiddleware.length) > 0) {
1345
- const workerConfigs = await Promise.all(middlewareManifest.sortedMiddleware.map(async (key) => {
1346
- const middleware = middlewareManifest.middleware[key];
1345
+ const sortedFunctions = [
1346
+ ...(!middlewareManifest
1347
+ ? []
1348
+ : middlewareManifest.sortedMiddleware.map(key => ({
1349
+ key,
1350
+ edgeFunction: middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.middleware[key],
1351
+ type: 'middleware',
1352
+ }))),
1353
+ ...Object.entries((_a = middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.functions) !== null && _a !== void 0 ? _a : {}).map(([key, edgeFunction]) => {
1354
+ return {
1355
+ key,
1356
+ edgeFunction,
1357
+ type: 'function',
1358
+ };
1359
+ }),
1360
+ ];
1361
+ if (middlewareManifest && sortedFunctions.length > 0) {
1362
+ const workerConfigs = await Promise.all(sortedFunctions.map(async ({ key, edgeFunction, type }) => {
1347
1363
  try {
1348
- const wrappedModuleSource = await (0, get_edge_function_source_1.getNextjsEdgeFunctionSource)(middleware.files, {
1349
- name: middleware.name,
1364
+ const wrappedModuleSource = await (0, get_edge_function_source_1.getNextjsEdgeFunctionSource)(edgeFunction.files, {
1365
+ name: edgeFunction.name,
1350
1366
  staticRoutes: routesManifest.staticRoutes,
1351
1367
  dynamicRoutes: routesManifest.dynamicRoutes.filter(r => !('isMiddleware' in r)),
1352
1368
  nextConfig: {
1353
1369
  basePath: routesManifest.basePath,
1354
1370
  i18n: routesManifest.i18n,
1355
1371
  },
1356
- }, path_1.default.resolve(entryPath, outputDirectory), middleware.wasm);
1372
+ }, path_1.default.resolve(entryPath, outputDirectory), edgeFunction.wasm);
1357
1373
  return {
1358
- page: middlewareManifest.middleware[key].page,
1374
+ type,
1375
+ page: edgeFunction.page,
1359
1376
  edgeFunction: (() => {
1360
1377
  var _a;
1361
1378
  const { source, map } = wrappedModuleSource.sourceAndMap();
1362
1379
  const transformedMap = (0, sourcemapped_1.stringifySourceMap)(transformSourceMap(map));
1363
- const wasmFiles = ((_a = middleware.wasm) !== null && _a !== void 0 ? _a : []).reduce((acc, { filePath, name }) => {
1380
+ const wasmFiles = ((_a = edgeFunction.wasm) !== null && _a !== void 0 ? _a : []).reduce((acc, { filePath, name }) => {
1364
1381
  const fullFilePath = path_1.default.join(entryPath, outputDirectory, filePath);
1365
1382
  acc[`wasm/${name}.wasm`] = new build_utils_1.FileFsRef({
1366
1383
  mode: 0o644,
@@ -1371,7 +1388,7 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1371
1388
  }, {});
1372
1389
  return new build_utils_1.EdgeFunction({
1373
1390
  deploymentTarget: 'v8-worker',
1374
- name: middleware.name,
1391
+ name: edgeFunction.name,
1375
1392
  files: {
1376
1393
  'index.js': new build_utils_1.FileBlob({
1377
1394
  data: source,
@@ -1388,10 +1405,10 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1388
1405
  ...wasmFiles,
1389
1406
  },
1390
1407
  entrypoint: 'index.js',
1391
- envVarsInUse: middleware.env,
1408
+ envVarsInUse: edgeFunction.env,
1392
1409
  });
1393
1410
  })(),
1394
- routeSrc: getRouteSrc(middlewareManifest.middleware[key], routesManifest),
1411
+ routeSrc: getRouteSrc(edgeFunction, routesManifest),
1395
1412
  };
1396
1413
  }
1397
1414
  catch (e) {
@@ -1403,16 +1420,23 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1403
1420
  staticRoutes: [],
1404
1421
  dynamicRouteMap: new Map(),
1405
1422
  edgeFunctions: {},
1406
- middleware: [],
1407
1423
  };
1408
1424
  for (const worker of workerConfigs.values()) {
1409
1425
  const edgeFile = worker.edgeFunction.name;
1410
- worker.edgeFunction.name = edgeFile.replace(/^pages\//, '');
1411
- source.edgeFunctions[edgeFile] = worker.edgeFunction;
1426
+ const shortPath = edgeFile.replace(/^pages\//, '');
1427
+ worker.edgeFunction.name = shortPath;
1428
+ source.edgeFunctions[shortPath] = worker.edgeFunction;
1412
1429
  const route = {
1413
1430
  continue: true,
1414
- middlewarePath: edgeFile,
1415
1431
  src: worker.routeSrc,
1432
+ ...(worker.type === 'middleware'
1433
+ ? {
1434
+ middlewarePath: shortPath,
1435
+ override: true,
1436
+ }
1437
+ : {
1438
+ dest: shortPath,
1439
+ }),
1416
1440
  };
1417
1441
  if (routesManifest.version > 3 && isDynamicRoute(worker.page)) {
1418
1442
  source.dynamicRouteMap.set(worker.page, route);
@@ -1427,7 +1451,6 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1427
1451
  staticRoutes: [],
1428
1452
  dynamicRouteMap: new Map(),
1429
1453
  edgeFunctions: {},
1430
- middleware: [],
1431
1454
  };
1432
1455
  }
1433
1456
  exports.getMiddlewareBundle = getMiddlewareBundle;
@@ -1448,6 +1471,7 @@ async function getMiddlewareManifest(entryPath, outputDirectory) {
1448
1471
  // eslint-disable-next-line @typescript-eslint/no-var-requires
1449
1472
  return require(middlewareManifestPath);
1450
1473
  }
1474
+ exports.getMiddlewareManifest = getMiddlewareManifest;
1451
1475
  /**
1452
1476
  * For an object containing middleware info and a routes manifest this will
1453
1477
  * generate a string with the route that will activate the middleware on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "2.8.67-canary.0",
3
+ "version": "2.8.67-canary.3",
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": "3.1.1-canary.0",
49
- "@vercel/nft": "0.19.0",
48
+ "@vercel/build-utils": "3.1.1-canary.2",
49
+ "@vercel/nft": "0.19.1",
50
50
  "@vercel/routing-utils": "1.13.3",
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": "e829ce47c356a06564551349e771b457ea95ac74"
73
+ "gitHead": "0a072ee8504ec6de9be9fe51b1659d67f56ec875"
74
74
  }