@vercel/next 3.1.20 → 3.1.23
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 +26214 -26224
- package/dist/utils.js +80 -35
- package/package.json +3 -3
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.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;
|
25
|
+
exports.upgradeMiddlewareManifest = 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"));
|
@@ -1439,7 +1439,7 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1439
1439
|
}),
|
1440
1440
|
});
|
1441
1441
|
})(),
|
1442
|
-
|
1442
|
+
routeMatchers: getRouteMatchers(edgeFunction, routesManifest),
|
1443
1443
|
};
|
1444
1444
|
}
|
1445
1445
|
catch (e) {
|
@@ -1462,26 +1462,29 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1462
1462
|
if (worker.type === 'function') {
|
1463
1463
|
continue;
|
1464
1464
|
}
|
1465
|
-
const
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
route.
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1465
|
+
for (const matcher of worker.routeMatchers) {
|
1466
|
+
const route = {
|
1467
|
+
continue: true,
|
1468
|
+
src: matcher.regexp,
|
1469
|
+
has: matcher.has,
|
1470
|
+
missing: [
|
1471
|
+
{
|
1472
|
+
type: 'header',
|
1473
|
+
key: 'x-prerender-revalidate',
|
1474
|
+
value: prerenderBypassToken,
|
1475
|
+
},
|
1476
|
+
],
|
1477
|
+
};
|
1478
|
+
route.middlewarePath = shortPath;
|
1479
|
+
if (isCorrectMiddlewareOrder) {
|
1480
|
+
route.override = true;
|
1481
|
+
}
|
1482
|
+
if (routesManifest.version > 3 && isDynamicRoute(worker.page)) {
|
1483
|
+
source.dynamicRouteMap.set(worker.page, route);
|
1484
|
+
}
|
1485
|
+
else {
|
1486
|
+
source.staticRoutes.push(route);
|
1487
|
+
}
|
1485
1488
|
}
|
1486
1489
|
}
|
1487
1490
|
return source;
|
@@ -1507,28 +1510,70 @@ async function getMiddlewareManifest(entryPath, outputDirectory) {
|
|
1507
1510
|
if (!hasManifest) {
|
1508
1511
|
return;
|
1509
1512
|
}
|
1510
|
-
|
1513
|
+
const manifest = (await fs_extra_1.default.readJSON(middlewareManifestPath));
|
1514
|
+
return manifest.version === 1
|
1515
|
+
? upgradeMiddlewareManifest(manifest)
|
1516
|
+
: manifest;
|
1511
1517
|
}
|
1512
1518
|
exports.getMiddlewareManifest = getMiddlewareManifest;
|
1519
|
+
function upgradeMiddlewareManifest(v1) {
|
1520
|
+
function updateInfo(v1Info) {
|
1521
|
+
const { regexp, ...rest } = v1Info;
|
1522
|
+
return {
|
1523
|
+
...rest,
|
1524
|
+
matchers: [{ regexp }],
|
1525
|
+
};
|
1526
|
+
}
|
1527
|
+
const middleware = Object.fromEntries(Object.entries(v1.middleware).map(([p, info]) => [p, updateInfo(info)]));
|
1528
|
+
const functions = v1.functions
|
1529
|
+
? Object.fromEntries(Object.entries(v1.functions).map(([p, info]) => [p, updateInfo(info)]))
|
1530
|
+
: undefined;
|
1531
|
+
return {
|
1532
|
+
...v1,
|
1533
|
+
version: 2,
|
1534
|
+
middleware,
|
1535
|
+
functions,
|
1536
|
+
};
|
1537
|
+
}
|
1538
|
+
exports.upgradeMiddlewareManifest = upgradeMiddlewareManifest;
|
1513
1539
|
/**
|
1514
1540
|
* For an object containing middleware info and a routes manifest this will
|
1515
1541
|
* generate a string with the route that will activate the middleware on
|
1516
1542
|
* Vercel Proxy.
|
1517
1543
|
*
|
1518
|
-
* @param param0 The middleware info including
|
1544
|
+
* @param param0 The middleware info including matchers and page.
|
1519
1545
|
* @param param1 The routes manifest
|
1520
|
-
* @returns
|
1546
|
+
* @returns matchers for the middleware route.
|
1521
1547
|
*/
|
1522
|
-
function
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1548
|
+
function getRouteMatchers(info, { basePath = '', i18n }) {
|
1549
|
+
function getRegexp(regexp) {
|
1550
|
+
if (info.page === '/') {
|
1551
|
+
return regexp;
|
1552
|
+
}
|
1553
|
+
const locale = i18n?.locales.length
|
1554
|
+
? `(?:/(${i18n.locales
|
1555
|
+
.map(locale => (0, escape_string_regexp_1.default)(locale))
|
1556
|
+
.join('|')}))?`
|
1557
|
+
: '';
|
1558
|
+
return `(?:^${basePath}${locale}${regexp.substring(1)})`;
|
1559
|
+
}
|
1560
|
+
function normalizeHas(has) {
|
1561
|
+
return has.map(v => v.type === 'header'
|
1562
|
+
? {
|
1563
|
+
...v,
|
1564
|
+
key: v.key.toLowerCase(),
|
1565
|
+
}
|
1566
|
+
: v);
|
1567
|
+
}
|
1568
|
+
return info.matchers.map(matcher => {
|
1569
|
+
const m = {
|
1570
|
+
regexp: getRegexp(matcher.regexp),
|
1571
|
+
};
|
1572
|
+
if (matcher.has) {
|
1573
|
+
m.has = normalizeHas(matcher.has);
|
1574
|
+
}
|
1575
|
+
return m;
|
1576
|
+
});
|
1532
1577
|
}
|
1533
1578
|
/**
|
1534
1579
|
* Makes the sources more human-readable in the source map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.23",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
"@types/semver": "6.0.0",
|
45
45
|
"@types/text-table": "0.2.1",
|
46
46
|
"@types/webpack-sources": "3.2.0",
|
47
|
-
"@vercel/build-utils": "5.
|
47
|
+
"@vercel/build-utils": "5.4.1",
|
48
48
|
"@vercel/nft": "0.21.0",
|
49
49
|
"@vercel/routing-utils": "2.0.2",
|
50
50
|
"async-sema": "3.0.1",
|
@@ -69,5 +69,5 @@
|
|
69
69
|
"typescript": "4.5.2",
|
70
70
|
"webpack-sources": "3.2.3"
|
71
71
|
},
|
72
|
-
"gitHead": "
|
72
|
+
"gitHead": "2906d83eaeddc72f9d874981dbe6698e812f3ca3"
|
73
73
|
}
|