@vercel/next 3.7.5 → 3.8.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/edge-function-source/get-edge-function-source.js +1 -1
- package/dist/index.js +77 -24
- package/dist/utils.js +68 -15
- package/package.json +4 -5
@@ -12,7 +12,7 @@ const constants_1 = require("./constants");
|
|
12
12
|
const zlib_1 = __importDefault(require("zlib"));
|
13
13
|
const util_1 = require("util");
|
14
14
|
const utils_1 = require("../utils");
|
15
|
-
// @ts-
|
15
|
+
// @ts-ignore this is a prebuilt file, based on `../../scripts/build-edge-function-template.js`
|
16
16
|
const ___get_nextjs_edge_function_js_1 = __importDefault(require("../../dist/___get-nextjs-edge-function.js"));
|
17
17
|
const gzip = (0, util_1.promisify)(zlib_1.default.gzip);
|
18
18
|
/**
|
package/dist/index.js
CHANGED
@@ -40433,7 +40433,7 @@ function convertTrailingSlash(enable, status = 308) {
|
|
40433
40433
|
exports.convertTrailingSlash = convertTrailingSlash;
|
40434
40434
|
function sourceToRegex(source) {
|
40435
40435
|
const keys = [];
|
40436
|
-
const r = path_to_regexp_1.pathToRegexp(source, keys, {
|
40436
|
+
const r = (0, path_to_regexp_1.pathToRegexp)(source, keys, {
|
40437
40437
|
strict: true,
|
40438
40438
|
sensitive: true,
|
40439
40439
|
delimiter: '/',
|
@@ -40499,7 +40499,7 @@ function replaceSegments(segments, hasItemSegments, destination, isRedirect, int
|
|
40499
40499
|
indexes[name] = '$' + name;
|
40500
40500
|
escapedDestination = escapeSegment(escapedDestination, name);
|
40501
40501
|
});
|
40502
|
-
const parsedDestination = url_1.parse(escapedDestination, true);
|
40502
|
+
const parsedDestination = (0, url_1.parse)(escapedDestination, true);
|
40503
40503
|
delete parsedDestination.href;
|
40504
40504
|
delete parsedDestination.path;
|
40505
40505
|
delete parsedDestination.search;
|
@@ -40514,9 +40514,9 @@ function replaceSegments(segments, hasItemSegments, destination, isRedirect, int
|
|
40514
40514
|
const hashKeys = [];
|
40515
40515
|
const hostnameKeys = [];
|
40516
40516
|
try {
|
40517
|
-
path_to_regexp_1.pathToRegexp(pathname, pathnameKeys);
|
40518
|
-
path_to_regexp_1.pathToRegexp(hash || '', hashKeys);
|
40519
|
-
path_to_regexp_1.pathToRegexp(hostname || '', hostnameKeys);
|
40517
|
+
(0, path_to_regexp_1.pathToRegexp)(pathname, pathnameKeys);
|
40518
|
+
(0, path_to_regexp_1.pathToRegexp)(hash || '', hashKeys);
|
40519
|
+
(0, path_to_regexp_1.pathToRegexp)(hostname || '', hostnameKeys);
|
40520
40520
|
}
|
40521
40521
|
catch (_) {
|
40522
40522
|
// this is not fatal so don't error when failing to parse the
|
@@ -40553,7 +40553,7 @@ function replaceSegments(segments, hasItemSegments, destination, isRedirect, int
|
|
40553
40553
|
}
|
40554
40554
|
}
|
40555
40555
|
}
|
40556
|
-
destination = url_1.format({
|
40556
|
+
destination = (0, url_1.format)({
|
40557
40557
|
...rest,
|
40558
40558
|
hostname,
|
40559
40559
|
pathname,
|
@@ -40572,7 +40572,7 @@ function safelyCompile(value, indexes, attemptDirectCompile) {
|
|
40572
40572
|
// Attempt compiling normally with path-to-regexp first and fall back
|
40573
40573
|
// to safely compiling to handle edge cases if path-to-regexp compile
|
40574
40574
|
// fails
|
40575
|
-
return path_to_regexp_1.compile(value, { validate: false })(indexes);
|
40575
|
+
return (0, path_to_regexp_1.compile)(value, { validate: false })(indexes);
|
40576
40576
|
}
|
40577
40577
|
catch (e) {
|
40578
40578
|
// non-fatal, we continue to safely compile
|
@@ -40595,7 +40595,7 @@ function safelyCompile(value, indexes, attemptDirectCompile) {
|
|
40595
40595
|
.replace(/--ESCAPED_PARAM_ASTERISK/g, '*');
|
40596
40596
|
// the value needs to start with a forward-slash to be compiled
|
40597
40597
|
// correctly
|
40598
|
-
return path_to_regexp_1.compile(`/${value}`, { validate: false })(indexes).slice(1);
|
40598
|
+
return (0, path_to_regexp_1.compile)(`/${value}`, { validate: false })(indexes).slice(1);
|
40599
40599
|
}
|
40600
40600
|
function toSegmentDest(index) {
|
40601
40601
|
const i = index + 1; // js is base 0, regex is base 1
|
@@ -40741,7 +40741,7 @@ const constants_1 = __webpack_require__(2152);
|
|
40741
40741
|
const zlib_1 = __importDefault(__webpack_require__(8761));
|
40742
40742
|
const util_1 = __webpack_require__(1669);
|
40743
40743
|
const utils_1 = __webpack_require__(6136);
|
40744
|
-
// @ts-
|
40744
|
+
// @ts-ignore this is a prebuilt file, based on `../../scripts/build-edge-function-template.js`
|
40745
40745
|
const ___get_nextjs_edge_function_js_1 = __importDefault(__webpack_require__(6223));
|
40746
40746
|
const gzip = (0, util_1.promisify)(zlib_1.default.gzip);
|
40747
40747
|
/**
|
@@ -44358,7 +44358,11 @@ exports.stringifySourceMap = stringifySourceMap;
|
|
44358
44358
|
|
44359
44359
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
44360
44360
|
if (k2 === undefined) k2 = k;
|
44361
|
-
Object.
|
44361
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
44362
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
44363
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
44364
|
+
}
|
44365
|
+
Object.defineProperty(o, k2, desc);
|
44362
44366
|
}) : (function(o, m, k, k2) {
|
44363
44367
|
if (k2 === undefined) k2 = k;
|
44364
44368
|
o[k2] = m[k];
|
@@ -45114,27 +45118,33 @@ async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
|
|
45114
45118
|
// TODO: this should be updated to get the pageExtensions
|
45115
45119
|
// value used during next build
|
45116
45120
|
const extensionsToTry = pageExtensions || ['js', 'jsx', 'ts', 'tsx'];
|
45117
|
-
|
45118
|
-
|
45119
|
-
|
45120
|
-
|
45121
|
-
|
45122
|
-
return path_1.default.relative(workPath, fsPath);
|
45123
|
-
}
|
45124
|
-
const extensionless = fsPath.slice(0, -3); // remove ".js"
|
45125
|
-
for (const ext of extensionsToTry) {
|
45126
|
-
fsPath = `${extensionless}.${ext}`;
|
45121
|
+
for (const pageType of ['pages', 'app']) {
|
45122
|
+
let fsPath = path_1.default.join(workPath, pageType, page);
|
45123
|
+
if (await usesSrcDirectory(workPath)) {
|
45124
|
+
fsPath = path_1.default.join(workPath, 'src', pageType, page);
|
45125
|
+
}
|
45127
45126
|
if (fs_extra_1.default.existsSync(fsPath)) {
|
45128
45127
|
return path_1.default.relative(workPath, fsPath);
|
45129
45128
|
}
|
45130
|
-
|
45131
|
-
if (isDirectory(extensionless)) {
|
45129
|
+
const extensionless = fsPath.replace(path_1.default.extname(fsPath), '');
|
45132
45130
|
for (const ext of extensionsToTry) {
|
45133
|
-
fsPath =
|
45131
|
+
fsPath = `${extensionless}.${ext}`;
|
45134
45132
|
if (fs_extra_1.default.existsSync(fsPath)) {
|
45135
45133
|
return path_1.default.relative(workPath, fsPath);
|
45136
45134
|
}
|
45137
45135
|
}
|
45136
|
+
if (isDirectory(extensionless)) {
|
45137
|
+
for (const ext of extensionsToTry) {
|
45138
|
+
fsPath = path_1.default.join(extensionless, `index.${ext}`);
|
45139
|
+
if (fs_extra_1.default.existsSync(fsPath)) {
|
45140
|
+
return path_1.default.relative(workPath, fsPath);
|
45141
|
+
}
|
45142
|
+
fsPath = path_1.default.join(extensionless, `route.${ext}`);
|
45143
|
+
if (fs_extra_1.default.existsSync(fsPath)) {
|
45144
|
+
return path_1.default.relative(workPath, fsPath);
|
45145
|
+
}
|
45146
|
+
}
|
45147
|
+
}
|
45138
45148
|
}
|
45139
45149
|
console.log(`WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(', ')}, this can cause functions config from \`vercel.json\` to not be applied`);
|
45140
45150
|
return '';
|
@@ -45842,6 +45852,47 @@ async function getPrivateOutputs(dir, entries) {
|
|
45842
45852
|
return { files, routes };
|
45843
45853
|
}
|
45844
45854
|
exports.getPrivateOutputs = getPrivateOutputs;
|
45855
|
+
const vercelFunctionRegionsVar = process.env.VERCEL_FUNCTION_REGIONS;
|
45856
|
+
let vercelFunctionRegions;
|
45857
|
+
if (vercelFunctionRegionsVar) {
|
45858
|
+
vercelFunctionRegions = vercelFunctionRegionsVar.split(',');
|
45859
|
+
}
|
45860
|
+
/**
|
45861
|
+
* Normalizes the regions config that comes from the Next.js edge functions manifest.
|
45862
|
+
* Ensures that config like `home` and `global` are converted to the corresponding Vercel region config.
|
45863
|
+
* In the future we'll want to make `home` and `global` part of the Build Output API.
|
45864
|
+
* - `home` refers to the regions set in vercel.json or on the Vercel dashboard project config.
|
45865
|
+
* - `global` refers to all regions.
|
45866
|
+
*/
|
45867
|
+
function normalizeRegions(regions) {
|
45868
|
+
if (typeof regions === 'string') {
|
45869
|
+
regions = [regions];
|
45870
|
+
}
|
45871
|
+
const newRegions = [];
|
45872
|
+
for (const region of regions) {
|
45873
|
+
// Explicitly mentioned as `home` is one of the explicit values for preferredRegion in Next.js.
|
45874
|
+
if (region === 'home') {
|
45875
|
+
if (vercelFunctionRegions) {
|
45876
|
+
// Includes the regions from the VERCEL_FUNCTION_REGIONS env var.
|
45877
|
+
newRegions.push(...vercelFunctionRegions);
|
45878
|
+
}
|
45879
|
+
continue;
|
45880
|
+
}
|
45881
|
+
// Explicitly mentioned as `global` is one of the explicit values for preferredRegion in Next.js.
|
45882
|
+
if (region === 'global') {
|
45883
|
+
// Uses `all` instead as that's how it's implemented on Vercel.
|
45884
|
+
newRegions.push('all');
|
45885
|
+
continue;
|
45886
|
+
}
|
45887
|
+
// Explicitly mentioned as `auto` is one of the explicit values for preferredRegion in Next.js.
|
45888
|
+
if (region === 'auto') {
|
45889
|
+
newRegions.push('auto');
|
45890
|
+
continue;
|
45891
|
+
}
|
45892
|
+
newRegions.push(region);
|
45893
|
+
}
|
45894
|
+
return [];
|
45895
|
+
}
|
45845
45896
|
async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, isCorrectMiddlewareOrder, prerenderBypassToken, nextVersion, appPathRoutesManifest, }) {
|
45846
45897
|
const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
|
45847
45898
|
const sortedFunctions = [
|
@@ -45915,7 +45966,9 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
45915
45966
|
...wasmFiles,
|
45916
45967
|
...assetFiles,
|
45917
45968
|
},
|
45918
|
-
regions: edgeFunction.regions
|
45969
|
+
regions: edgeFunction.regions
|
45970
|
+
? normalizeRegions(edgeFunction.regions)
|
45971
|
+
: undefined,
|
45919
45972
|
entrypoint: 'index.js',
|
45920
45973
|
envVarsInUse: edgeFunction.env,
|
45921
45974
|
assets: (edgeFunction.assets ?? []).map(({ name }) => {
|
package/dist/utils.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -757,27 +761,33 @@ async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
|
|
757
761
|
// TODO: this should be updated to get the pageExtensions
|
758
762
|
// value used during next build
|
759
763
|
const extensionsToTry = pageExtensions || ['js', 'jsx', 'ts', 'tsx'];
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
return path_1.default.relative(workPath, fsPath);
|
766
|
-
}
|
767
|
-
const extensionless = fsPath.slice(0, -3); // remove ".js"
|
768
|
-
for (const ext of extensionsToTry) {
|
769
|
-
fsPath = `${extensionless}.${ext}`;
|
764
|
+
for (const pageType of ['pages', 'app']) {
|
765
|
+
let fsPath = path_1.default.join(workPath, pageType, page);
|
766
|
+
if (await usesSrcDirectory(workPath)) {
|
767
|
+
fsPath = path_1.default.join(workPath, 'src', pageType, page);
|
768
|
+
}
|
770
769
|
if (fs_extra_1.default.existsSync(fsPath)) {
|
771
770
|
return path_1.default.relative(workPath, fsPath);
|
772
771
|
}
|
773
|
-
|
774
|
-
if (isDirectory(extensionless)) {
|
772
|
+
const extensionless = fsPath.replace(path_1.default.extname(fsPath), '');
|
775
773
|
for (const ext of extensionsToTry) {
|
776
|
-
fsPath =
|
774
|
+
fsPath = `${extensionless}.${ext}`;
|
777
775
|
if (fs_extra_1.default.existsSync(fsPath)) {
|
778
776
|
return path_1.default.relative(workPath, fsPath);
|
779
777
|
}
|
780
778
|
}
|
779
|
+
if (isDirectory(extensionless)) {
|
780
|
+
for (const ext of extensionsToTry) {
|
781
|
+
fsPath = path_1.default.join(extensionless, `index.${ext}`);
|
782
|
+
if (fs_extra_1.default.existsSync(fsPath)) {
|
783
|
+
return path_1.default.relative(workPath, fsPath);
|
784
|
+
}
|
785
|
+
fsPath = path_1.default.join(extensionless, `route.${ext}`);
|
786
|
+
if (fs_extra_1.default.existsSync(fsPath)) {
|
787
|
+
return path_1.default.relative(workPath, fsPath);
|
788
|
+
}
|
789
|
+
}
|
790
|
+
}
|
781
791
|
}
|
782
792
|
console.log(`WARNING: Unable to find source file for page ${page} with extensions: ${extensionsToTry.join(', ')}, this can cause functions config from \`vercel.json\` to not be applied`);
|
783
793
|
return '';
|
@@ -1485,6 +1495,47 @@ async function getPrivateOutputs(dir, entries) {
|
|
1485
1495
|
return { files, routes };
|
1486
1496
|
}
|
1487
1497
|
exports.getPrivateOutputs = getPrivateOutputs;
|
1498
|
+
const vercelFunctionRegionsVar = process.env.VERCEL_FUNCTION_REGIONS;
|
1499
|
+
let vercelFunctionRegions;
|
1500
|
+
if (vercelFunctionRegionsVar) {
|
1501
|
+
vercelFunctionRegions = vercelFunctionRegionsVar.split(',');
|
1502
|
+
}
|
1503
|
+
/**
|
1504
|
+
* Normalizes the regions config that comes from the Next.js edge functions manifest.
|
1505
|
+
* Ensures that config like `home` and `global` are converted to the corresponding Vercel region config.
|
1506
|
+
* In the future we'll want to make `home` and `global` part of the Build Output API.
|
1507
|
+
* - `home` refers to the regions set in vercel.json or on the Vercel dashboard project config.
|
1508
|
+
* - `global` refers to all regions.
|
1509
|
+
*/
|
1510
|
+
function normalizeRegions(regions) {
|
1511
|
+
if (typeof regions === 'string') {
|
1512
|
+
regions = [regions];
|
1513
|
+
}
|
1514
|
+
const newRegions = [];
|
1515
|
+
for (const region of regions) {
|
1516
|
+
// Explicitly mentioned as `home` is one of the explicit values for preferredRegion in Next.js.
|
1517
|
+
if (region === 'home') {
|
1518
|
+
if (vercelFunctionRegions) {
|
1519
|
+
// Includes the regions from the VERCEL_FUNCTION_REGIONS env var.
|
1520
|
+
newRegions.push(...vercelFunctionRegions);
|
1521
|
+
}
|
1522
|
+
continue;
|
1523
|
+
}
|
1524
|
+
// Explicitly mentioned as `global` is one of the explicit values for preferredRegion in Next.js.
|
1525
|
+
if (region === 'global') {
|
1526
|
+
// Uses `all` instead as that's how it's implemented on Vercel.
|
1527
|
+
newRegions.push('all');
|
1528
|
+
continue;
|
1529
|
+
}
|
1530
|
+
// Explicitly mentioned as `auto` is one of the explicit values for preferredRegion in Next.js.
|
1531
|
+
if (region === 'auto') {
|
1532
|
+
newRegions.push('auto');
|
1533
|
+
continue;
|
1534
|
+
}
|
1535
|
+
newRegions.push(region);
|
1536
|
+
}
|
1537
|
+
return [];
|
1538
|
+
}
|
1488
1539
|
async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, isCorrectMiddlewareOrder, prerenderBypassToken, nextVersion, appPathRoutesManifest, }) {
|
1489
1540
|
const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
|
1490
1541
|
const sortedFunctions = [
|
@@ -1558,7 +1609,9 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1558
1609
|
...wasmFiles,
|
1559
1610
|
...assetFiles,
|
1560
1611
|
},
|
1561
|
-
regions: edgeFunction.regions
|
1612
|
+
regions: edgeFunction.regions
|
1613
|
+
? normalizeRegions(edgeFunction.regions)
|
1614
|
+
: undefined,
|
1562
1615
|
entrypoint: 'index.js',
|
1563
1616
|
envVarsInUse: edgeFunction.env,
|
1564
1617
|
assets: (edgeFunction.assets ?? []).map(({ name }) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.8.0",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
@@ -35,9 +35,9 @@
|
|
35
35
|
"@types/semver": "6.0.0",
|
36
36
|
"@types/text-table": "0.2.1",
|
37
37
|
"@types/webpack-sources": "3.2.0",
|
38
|
-
"@vercel/build-utils": "6.7.
|
38
|
+
"@vercel/build-utils": "6.7.2",
|
39
39
|
"@vercel/nft": "0.22.5",
|
40
|
-
"@vercel/routing-utils": "2.2.
|
40
|
+
"@vercel/routing-utils": "2.2.1",
|
41
41
|
"async-sema": "3.0.1",
|
42
42
|
"buffer-crc32": "0.2.13",
|
43
43
|
"bytes": "3.1.2",
|
@@ -58,8 +58,7 @@
|
|
58
58
|
"source-map": "0.7.3",
|
59
59
|
"test-listen": "1.1.0",
|
60
60
|
"text-table": "0.2.0",
|
61
|
-
"typescript": "4.5.2",
|
62
61
|
"webpack-sources": "3.2.3"
|
63
62
|
},
|
64
|
-
"gitHead": "
|
63
|
+
"gitHead": "b5db13c97035d0eae04a5e075ae74e488d1298d6"
|
65
64
|
}
|