@vercel/static-build 2.11.9 → 2.11.11
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 +150 -7
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -22994,7 +22994,7 @@ var require_utils4 = __commonJS({
|
|
|
22994
22994
|
};
|
|
22995
22995
|
}
|
|
22996
22996
|
}
|
|
22997
|
-
const hasVercelToml =
|
|
22997
|
+
const hasVercelToml = await fs5.hasPath("vercel.toml");
|
|
22998
22998
|
if (hasVercelToml) {
|
|
22999
22999
|
try {
|
|
23000
23000
|
const { parse: tomlParse } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
@@ -29298,7 +29298,9 @@ var require_detect_builders = __commonJS({
|
|
|
29298
29298
|
detectApiExtensions: () => detectApiExtensions2,
|
|
29299
29299
|
detectBuilders: () => detectBuilders2,
|
|
29300
29300
|
detectOutputDirectory: () => detectOutputDirectory2,
|
|
29301
|
-
|
|
29301
|
+
getProxyBuilder: () => getProxyBuilder2,
|
|
29302
|
+
sortFiles: () => sortFiles,
|
|
29303
|
+
validateProxyConfig: () => validateProxyConfig2
|
|
29302
29304
|
});
|
|
29303
29305
|
module2.exports = __toCommonJS2(detect_builders_exports);
|
|
29304
29306
|
var import_minimatch = __toESM2(require_minimatch());
|
|
@@ -29309,7 +29311,7 @@ var require_detect_builders = __commonJS({
|
|
|
29309
29311
|
var import_build_utils5 = require("@vercel/build-utils");
|
|
29310
29312
|
var import_get_services_builders = require_get_services_builders();
|
|
29311
29313
|
var REGEX_MIDDLEWARE_FILES = "middleware.[jt]s";
|
|
29312
|
-
var
|
|
29314
|
+
var VERCEL_PLATFORM_FILES = [
|
|
29313
29315
|
"api/**",
|
|
29314
29316
|
"node_modules/**",
|
|
29315
29317
|
REGEX_MIDDLEWARE_FILES,
|
|
@@ -29321,8 +29323,18 @@ var require_detect_builders = __commonJS({
|
|
|
29321
29323
|
"bun.lockb",
|
|
29322
29324
|
".gitignore",
|
|
29323
29325
|
"README.md"
|
|
29324
|
-
]
|
|
29325
|
-
var
|
|
29326
|
+
];
|
|
29327
|
+
var REGEX_VERCEL_PLATFORM_FILES = VERCEL_PLATFORM_FILES.join(",");
|
|
29328
|
+
function escapeMinimatchPath(path6) {
|
|
29329
|
+
return path6.replace(/([\\,*?[\]{}()!+@])/g, "\\$1");
|
|
29330
|
+
}
|
|
29331
|
+
function getStaticFilesPattern(additionalExclusions = []) {
|
|
29332
|
+
return `!{${[
|
|
29333
|
+
...VERCEL_PLATFORM_FILES,
|
|
29334
|
+
...additionalExclusions.map(escapeMinimatchPath)
|
|
29335
|
+
].join(",")}}`;
|
|
29336
|
+
}
|
|
29337
|
+
var REGEX_NON_VERCEL_PLATFORM_FILES2 = getStaticFilesPattern();
|
|
29326
29338
|
var slugToFramework = new Map(
|
|
29327
29339
|
import_frameworks2.frameworkList.map((f) => [f.slug, f])
|
|
29328
29340
|
);
|
|
@@ -29378,6 +29390,18 @@ var require_detect_builders = __commonJS({
|
|
|
29378
29390
|
};
|
|
29379
29391
|
}
|
|
29380
29392
|
const { framework } = projectSettings;
|
|
29393
|
+
const proxyError = validateProxy(options, files, framework);
|
|
29394
|
+
if (proxyError) {
|
|
29395
|
+
return {
|
|
29396
|
+
builders: null,
|
|
29397
|
+
errors: [proxyError],
|
|
29398
|
+
warnings: [],
|
|
29399
|
+
defaultRoutes: null,
|
|
29400
|
+
redirectRoutes: null,
|
|
29401
|
+
rewriteRoutes: null,
|
|
29402
|
+
errorRoutes: null
|
|
29403
|
+
};
|
|
29404
|
+
}
|
|
29381
29405
|
const servicesConfig = services ?? experimentalServicesV2;
|
|
29382
29406
|
const configuredServices = servicesConfig ?? experimentalServicesV1;
|
|
29383
29407
|
const configuredServicesType = servicesConfig ? services ? "services" : "experimentalServicesV2" : "experimentalServices";
|
|
@@ -29394,6 +29418,12 @@ var require_detect_builders = __commonJS({
|
|
|
29394
29418
|
...(0, import_get_services_builders.warnIgnoredDirectories)(files, configuredServices)
|
|
29395
29419
|
);
|
|
29396
29420
|
}
|
|
29421
|
+
if (!result.errors && options.proxy) {
|
|
29422
|
+
result.builders = [
|
|
29423
|
+
getProxyBuilder2(options.proxy, options.tag, options.functions),
|
|
29424
|
+
...result.builders ?? []
|
|
29425
|
+
];
|
|
29426
|
+
}
|
|
29397
29427
|
return result;
|
|
29398
29428
|
}
|
|
29399
29429
|
const errors = [];
|
|
@@ -29444,6 +29474,9 @@ var require_detect_builders = __commonJS({
|
|
|
29444
29474
|
const apiRoutes = [];
|
|
29445
29475
|
const dynamicRoutes = [];
|
|
29446
29476
|
for (const fileName of sortedFiles) {
|
|
29477
|
+
if (fileName === options.proxy?.entrypoint) {
|
|
29478
|
+
continue;
|
|
29479
|
+
}
|
|
29447
29480
|
const apiBuilder = await maybeGetApiBuilder(fileName, apiMatches, options);
|
|
29448
29481
|
if (apiBuilder) {
|
|
29449
29482
|
const { routeError, apiRoute, isDynamic } = getApiRoute(
|
|
@@ -29486,6 +29519,15 @@ var require_detect_builders = __commonJS({
|
|
|
29486
29519
|
fallbackEntrypoint = fileName;
|
|
29487
29520
|
}
|
|
29488
29521
|
}
|
|
29522
|
+
if (options.proxy) {
|
|
29523
|
+
const proxyBuilder = getProxyBuilder2(
|
|
29524
|
+
options.proxy,
|
|
29525
|
+
options.tag,
|
|
29526
|
+
options.functions
|
|
29527
|
+
);
|
|
29528
|
+
addToUsedFunctions(proxyBuilder);
|
|
29529
|
+
apiBuilders.unshift(proxyBuilder);
|
|
29530
|
+
}
|
|
29489
29531
|
if (!makeFrontendStatic && (hasBuildScript(pkg) || buildCommand || framework)) {
|
|
29490
29532
|
frontendBuilder = detectFrontBuilder(
|
|
29491
29533
|
pkg,
|
|
@@ -29519,13 +29561,31 @@ var require_detect_builders = __commonJS({
|
|
|
29519
29561
|
} else if (apiBuilders.length && hasNoneApiFiles) {
|
|
29520
29562
|
frontendBuilder = {
|
|
29521
29563
|
use: "@vercel/static",
|
|
29522
|
-
src:
|
|
29564
|
+
src: getStaticFilesPattern(
|
|
29565
|
+
options.proxy ? [options.proxy.entrypoint] : []
|
|
29566
|
+
),
|
|
29523
29567
|
config: {
|
|
29524
29568
|
zeroConfig: true
|
|
29525
29569
|
}
|
|
29526
29570
|
};
|
|
29527
29571
|
}
|
|
29528
29572
|
}
|
|
29573
|
+
if (options.proxy && frontendBuilder && (0, import_is_official_runtime.isOfficialRuntime)("next", frontendBuilder.use)) {
|
|
29574
|
+
return {
|
|
29575
|
+
builders: null,
|
|
29576
|
+
errors: [
|
|
29577
|
+
{
|
|
29578
|
+
code: "proxy_framework_conflict",
|
|
29579
|
+
message: "The `proxy` property cannot be used with Next.js because the framework builds its own routing middleware."
|
|
29580
|
+
}
|
|
29581
|
+
],
|
|
29582
|
+
warnings,
|
|
29583
|
+
defaultRoutes: null,
|
|
29584
|
+
redirectRoutes: null,
|
|
29585
|
+
rewriteRoutes: null,
|
|
29586
|
+
errorRoutes: null
|
|
29587
|
+
};
|
|
29588
|
+
}
|
|
29529
29589
|
const unusedFunctionError = checkUnusedFunctions(
|
|
29530
29590
|
frontendBuilder,
|
|
29531
29591
|
usedFunctions,
|
|
@@ -29592,7 +29652,7 @@ var require_detect_builders = __commonJS({
|
|
|
29592
29652
|
};
|
|
29593
29653
|
}
|
|
29594
29654
|
async function maybeGetApiBuilder(fileName, apiMatches, options) {
|
|
29595
|
-
const middleware = fileName === "middleware.js" || fileName === "middleware.ts";
|
|
29655
|
+
const middleware = !options.proxy && (fileName === "middleware.js" || fileName === "middleware.ts");
|
|
29596
29656
|
if (middleware && options.projectSettings?.framework === "nextjs") {
|
|
29597
29657
|
return null;
|
|
29598
29658
|
}
|
|
@@ -29665,6 +29725,30 @@ var require_detect_builders = __commonJS({
|
|
|
29665
29725
|
const func = keys.find((key) => key === fileName || (0, import_minimatch.default)(fileName, key));
|
|
29666
29726
|
return func ? { fnPattern: func, func: functions[func] } : { fnPattern: null, func: null };
|
|
29667
29727
|
}
|
|
29728
|
+
function getProxyBuilder2(proxy, tag, functions = {}) {
|
|
29729
|
+
const { fnPattern, func } = getFunction(proxy.entrypoint, { functions });
|
|
29730
|
+
const runtime = func?.runtime;
|
|
29731
|
+
const config = {
|
|
29732
|
+
zeroConfig: true,
|
|
29733
|
+
middleware: true,
|
|
29734
|
+
...!runtime ? { middlewareRuntime: "nodejs" } : {},
|
|
29735
|
+
...proxy.matcher ? { middlewareMatcher: proxy.matcher } : {}
|
|
29736
|
+
};
|
|
29737
|
+
if (fnPattern && func) {
|
|
29738
|
+
config.functions = { [fnPattern]: func };
|
|
29739
|
+
if (func.includeFiles) {
|
|
29740
|
+
config.includeFiles = func.includeFiles;
|
|
29741
|
+
}
|
|
29742
|
+
if (func.excludeFiles) {
|
|
29743
|
+
config.excludeFiles = func.excludeFiles;
|
|
29744
|
+
}
|
|
29745
|
+
}
|
|
29746
|
+
return {
|
|
29747
|
+
src: proxy.entrypoint,
|
|
29748
|
+
use: runtime || `@vercel/node${tag ? `@${tag}` : ""}`,
|
|
29749
|
+
config
|
|
29750
|
+
};
|
|
29751
|
+
}
|
|
29668
29752
|
function getApiMatches() {
|
|
29669
29753
|
const config = { zeroConfig: true };
|
|
29670
29754
|
return [
|
|
@@ -29680,6 +29764,63 @@ var require_detect_builders = __commonJS({
|
|
|
29680
29764
|
{ src: "api/**/*.rs", use: `@vercel/rust`, config }
|
|
29681
29765
|
];
|
|
29682
29766
|
}
|
|
29767
|
+
function validateProxyConfig2(proxy) {
|
|
29768
|
+
if (typeof proxy !== "object" || typeof proxy.entrypoint !== "string" || !proxy.entrypoint) {
|
|
29769
|
+
return {
|
|
29770
|
+
code: "invalid_proxy",
|
|
29771
|
+
message: "The `proxy` property must contain an `entrypoint` string that references a `.js` or `.ts` file."
|
|
29772
|
+
};
|
|
29773
|
+
}
|
|
29774
|
+
const entrypoint = proxy.entrypoint;
|
|
29775
|
+
const segments = entrypoint.split("/");
|
|
29776
|
+
if (entrypoint.startsWith("/") || entrypoint.includes("\\") || segments.includes(".") || segments.includes("..") || /[?#\u0000-\u001f]/.test(entrypoint)) {
|
|
29777
|
+
return {
|
|
29778
|
+
code: "invalid_proxy_entrypoint",
|
|
29779
|
+
message: "The `proxy.entrypoint` path must be relative to the project root and cannot contain traversal, query, fragment, or control characters."
|
|
29780
|
+
};
|
|
29781
|
+
}
|
|
29782
|
+
if (!/\.(?:js|ts)$/.test(entrypoint) || entrypoint.endsWith(".d.ts")) {
|
|
29783
|
+
return {
|
|
29784
|
+
code: "invalid_proxy_entrypoint",
|
|
29785
|
+
message: "The `proxy.entrypoint` path must end in `.js` or `.ts` and reference an executable file."
|
|
29786
|
+
};
|
|
29787
|
+
}
|
|
29788
|
+
if (proxy.matcher !== void 0) {
|
|
29789
|
+
const matchers = Array.isArray(proxy.matcher) ? proxy.matcher : [proxy.matcher];
|
|
29790
|
+
if (matchers.length === 0 || matchers.some(
|
|
29791
|
+
(matcher) => typeof matcher !== "string" || !matcher.startsWith("/")
|
|
29792
|
+
)) {
|
|
29793
|
+
return {
|
|
29794
|
+
code: "invalid_proxy_matcher",
|
|
29795
|
+
message: "The `proxy.matcher` value must be a path matcher starting with `/`, or an array of path matchers starting with `/`."
|
|
29796
|
+
};
|
|
29797
|
+
}
|
|
29798
|
+
}
|
|
29799
|
+
return null;
|
|
29800
|
+
}
|
|
29801
|
+
function validateProxy(options, files, framework) {
|
|
29802
|
+
const { proxy } = options;
|
|
29803
|
+
if (!proxy) {
|
|
29804
|
+
return null;
|
|
29805
|
+
}
|
|
29806
|
+
const configError = validateProxyConfig2(proxy);
|
|
29807
|
+
if (configError) {
|
|
29808
|
+
return configError;
|
|
29809
|
+
}
|
|
29810
|
+
if (!files.includes(proxy.entrypoint)) {
|
|
29811
|
+
return {
|
|
29812
|
+
code: "proxy_entrypoint_not_found",
|
|
29813
|
+
message: `The proxy entrypoint \`${proxy.entrypoint}\` does not exist. Set \`proxy.entrypoint\` to an existing \`.js\` or \`.ts\` file.`
|
|
29814
|
+
};
|
|
29815
|
+
}
|
|
29816
|
+
if (framework === "nextjs" || framework === "astro") {
|
|
29817
|
+
return {
|
|
29818
|
+
code: "proxy_framework_conflict",
|
|
29819
|
+
message: `The \`proxy\` property cannot be used with ${framework === "nextjs" ? "Next.js" : "Astro"} because the framework builds its own routing middleware.`
|
|
29820
|
+
};
|
|
29821
|
+
}
|
|
29822
|
+
return null;
|
|
29823
|
+
}
|
|
29683
29824
|
function hasBuildScript(pkg) {
|
|
29684
29825
|
const { scripts = {} } = pkg || {};
|
|
29685
29826
|
return Boolean(scripts && scripts["build"]);
|
|
@@ -34714,6 +34855,7 @@ var require_dist8 = __commonJS({
|
|
|
34714
34855
|
getInternalServiceWorkerPath: () => import_utils.getInternalServiceWorkerPath,
|
|
34715
34856
|
getInternalServiceWorkerPathPrefix: () => import_utils.getInternalServiceWorkerPathPrefix,
|
|
34716
34857
|
getProjectPaths: () => import_get_project_paths.getProjectPaths,
|
|
34858
|
+
getProxyBuilder: () => import_detect_builders.getProxyBuilder,
|
|
34717
34859
|
getServicesBuilders: () => import_get_services_builders.getServicesBuilders,
|
|
34718
34860
|
getWorkspacePackagePaths: () => import_get_workspace_package_paths.getWorkspacePackagePaths,
|
|
34719
34861
|
getWorkspaces: () => import_get_workspaces.getWorkspaces,
|
|
@@ -34727,6 +34869,7 @@ var require_dist8 = __commonJS({
|
|
|
34727
34869
|
packageManagers: () => import_package_managers.packageManagers,
|
|
34728
34870
|
resolveAllConfiguredServicesV2: () => import_resolve_v2.resolveAllConfiguredServicesV2,
|
|
34729
34871
|
resolveConfiguredServiceV2: () => import_resolve_v2.resolveConfiguredServiceV2,
|
|
34872
|
+
validateProxyConfig: () => import_detect_builders.validateProxyConfig,
|
|
34730
34873
|
validateServiceConfigV2: () => import_resolve_v2.validateServiceConfigV2,
|
|
34731
34874
|
workspaceManagers: () => import_workspace_managers.workspaceManagers
|
|
34732
34875
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/static-build",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/build-step",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"ts-morph": "12.0.0",
|
|
17
|
-
"@vercel/gatsby-plugin-vercel-
|
|
17
|
+
"@vercel/gatsby-plugin-vercel-builder": "2.2.31",
|
|
18
18
|
"@vercel/static-config": "3.4.0",
|
|
19
|
-
"@vercel/gatsby-plugin-vercel-
|
|
19
|
+
"@vercel/gatsby-plugin-vercel-analytics": "1.0.11"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/aws-lambda": "8.10.64",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"semver": "7.5.2",
|
|
38
38
|
"tree-kill": "1.2.2",
|
|
39
39
|
"vitest": "2.0.3",
|
|
40
|
-
"@vercel/
|
|
40
|
+
"@vercel/frameworks": "3.30.7",
|
|
41
|
+
"@vercel/build-utils": "13.36.1",
|
|
41
42
|
"@vercel/error-utils": "2.2.0",
|
|
42
|
-
"@vercel/fs-detectors": "6.
|
|
43
|
-
"@vercel/routing-utils": "6.4.0"
|
|
44
|
-
"@vercel/frameworks": "3.30.7"
|
|
43
|
+
"@vercel/fs-detectors": "6.14.1",
|
|
44
|
+
"@vercel/routing-utils": "6.4.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "node ../../utils/build-builder.mjs",
|