@vercel/build-utils 14.0.4 → 14.1.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/CHANGELOG.md +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2808 -0
- package/dist/middleware-matcher.d.ts +15 -0
- package/dist/middleware-matcher.js +63 -0
- package/package.json +4 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a path matcher (a string or an array of strings, each beginning with
|
|
3
|
+
* "/") into a single route `src` regular-expression source. A falsy matcher
|
|
4
|
+
* means "match everything" and yields the catch-all `^/.*$`.
|
|
5
|
+
*
|
|
6
|
+
* Shared by the Node builder's middleware routes and the Python builder's
|
|
7
|
+
* platform-proxy routes so both emit identical `src` patterns for the
|
|
8
|
+
* `before_filesystem` routing phase.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRegExpFromMatchers(matcherOrMatchers: unknown): string;
|
|
11
|
+
/**
|
|
12
|
+
* Reconcile a matcher configured out-of-band (e.g. `proxy.matcher`) with one a
|
|
13
|
+
* source file exports as `config.matcher`. Exactly one may be set.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveMiddlewareMatcher(configuredMatcher: string | string[] | undefined, sourceMatcher: unknown, entrypoint: string): unknown;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var middleware_matcher_exports = {};
|
|
20
|
+
__export(middleware_matcher_exports, {
|
|
21
|
+
getRegExpFromMatchers: () => getRegExpFromMatchers,
|
|
22
|
+
resolveMiddlewareMatcher: () => resolveMiddlewareMatcher
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(middleware_matcher_exports);
|
|
25
|
+
var import_routing_utils = require("@vercel/routing-utils");
|
|
26
|
+
function getRegExpFromMatchers(matcherOrMatchers) {
|
|
27
|
+
if (!matcherOrMatchers) {
|
|
28
|
+
return "^/.*$";
|
|
29
|
+
}
|
|
30
|
+
const matchers = Array.isArray(matcherOrMatchers) ? matcherOrMatchers : [matcherOrMatchers];
|
|
31
|
+
const regExps = matchers.flatMap(getRegExpFromMatcher).join("|");
|
|
32
|
+
return regExps;
|
|
33
|
+
}
|
|
34
|
+
function resolveMiddlewareMatcher(configuredMatcher, sourceMatcher, entrypoint) {
|
|
35
|
+
if (configuredMatcher !== void 0 && sourceMatcher !== void 0) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`${entrypoint}: \`proxy.matcher\` in vercel.json conflicts with \`config.matcher\` exported from the proxy entrypoint. Configure the matcher in only one location.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return configuredMatcher ?? sourceMatcher;
|
|
41
|
+
}
|
|
42
|
+
function getRegExpFromMatcher(matcher, _index, allMatchers) {
|
|
43
|
+
if (typeof matcher !== "string") {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"Middleware's `config.matcher` must be a path matcher (string) or an array of path matchers (string[])"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (!matcher.startsWith("/")) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Middleware's \`config.matcher\` values must start with "/". Received: ${matcher}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const regExps = [(0, import_routing_utils.pathToRegexp)("316", matcher).source];
|
|
54
|
+
if (matcher === "/" && !allMatchers.includes("/index")) {
|
|
55
|
+
regExps.push((0, import_routing_utils.pathToRegexp)("491", "/index").source);
|
|
56
|
+
}
|
|
57
|
+
return regExps;
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
getRegExpFromMatchers,
|
|
62
|
+
resolveMiddlewareMatcher
|
|
63
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/build-utils",
|
|
3
|
-
"version": "14.0
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"cjs-module-lexer": "1.2.3",
|
|
15
15
|
"es-module-lexer": "1.5.0",
|
|
16
|
-
"@vercel/python-analysis": "0.13.
|
|
16
|
+
"@vercel/python-analysis": "0.13.2"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/async-retry": "^1.2.1",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"vitest": "4.1.10",
|
|
54
54
|
"typescript": "4.9.5",
|
|
55
55
|
"yazl": "2.5.1",
|
|
56
|
-
"@vercel/
|
|
57
|
-
"@vercel/
|
|
56
|
+
"@vercel/routing-utils": "6.5.0",
|
|
57
|
+
"@vercel/error-utils": "2.2.1"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "node build.mjs",
|