@vercel/static-build 2.9.11 → 2.9.12
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 +104 -13
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -22826,6 +22826,84 @@ var require_resolve = __commonJS({
|
|
|
22826
22826
|
const normalized = (0, import_routing_utils.normalizeRoutePrefix)(routePrefix);
|
|
22827
22827
|
return normalized === import_utils.INTERNAL_SERVICE_PREFIX || normalized.startsWith(`${import_utils.INTERNAL_SERVICE_PREFIX}/`);
|
|
22828
22828
|
}
|
|
22829
|
+
function resolveServiceRoutingConfig(name, config) {
|
|
22830
|
+
const hasLegacyRoutePrefix = typeof config.routePrefix === "string";
|
|
22831
|
+
const hasLegacySubdomain = typeof config.subdomain === "string";
|
|
22832
|
+
if (config.mount === void 0) {
|
|
22833
|
+
return {
|
|
22834
|
+
routing: {
|
|
22835
|
+
routePrefix: config.routePrefix,
|
|
22836
|
+
subdomain: config.subdomain,
|
|
22837
|
+
routePrefixConfigured: hasLegacyRoutePrefix
|
|
22838
|
+
}
|
|
22839
|
+
};
|
|
22840
|
+
}
|
|
22841
|
+
if (hasLegacyRoutePrefix || hasLegacySubdomain) {
|
|
22842
|
+
return {
|
|
22843
|
+
error: {
|
|
22844
|
+
code: "CONFLICTING_MOUNT_CONFIG",
|
|
22845
|
+
message: `Service "${name}" cannot mix "mount" with "routePrefix" or "subdomain". Use only one routing configuration style.`,
|
|
22846
|
+
serviceName: name
|
|
22847
|
+
}
|
|
22848
|
+
};
|
|
22849
|
+
}
|
|
22850
|
+
if (typeof config.mount === "string") {
|
|
22851
|
+
return {
|
|
22852
|
+
routing: {
|
|
22853
|
+
routePrefix: config.mount,
|
|
22854
|
+
routePrefixConfigured: true
|
|
22855
|
+
}
|
|
22856
|
+
};
|
|
22857
|
+
}
|
|
22858
|
+
if (!config.mount || typeof config.mount !== "object" || Array.isArray(config.mount)) {
|
|
22859
|
+
return {
|
|
22860
|
+
error: {
|
|
22861
|
+
code: "INVALID_MOUNT",
|
|
22862
|
+
message: `Service "${name}" has invalid "mount" config. Use a string path such as "/api" or an object like { path: "/api", subdomain: "api" }.`,
|
|
22863
|
+
serviceName: name
|
|
22864
|
+
}
|
|
22865
|
+
};
|
|
22866
|
+
}
|
|
22867
|
+
const hasInvalidMountKeys = Object.keys(config.mount).some(
|
|
22868
|
+
(key) => key !== "path" && key !== "subdomain"
|
|
22869
|
+
);
|
|
22870
|
+
if (hasInvalidMountKeys) {
|
|
22871
|
+
return {
|
|
22872
|
+
error: {
|
|
22873
|
+
code: "INVALID_MOUNT",
|
|
22874
|
+
message: `Service "${name}" has invalid "mount" config. Only "path" and "subdomain" are supported.`,
|
|
22875
|
+
serviceName: name
|
|
22876
|
+
}
|
|
22877
|
+
};
|
|
22878
|
+
}
|
|
22879
|
+
const mountPath = config.mount.path;
|
|
22880
|
+
const mountSubdomain = config.mount.subdomain;
|
|
22881
|
+
if (mountPath !== void 0 && typeof mountPath !== "string" || mountSubdomain !== void 0 && typeof mountSubdomain !== "string") {
|
|
22882
|
+
return {
|
|
22883
|
+
error: {
|
|
22884
|
+
code: "INVALID_MOUNT",
|
|
22885
|
+
message: `Service "${name}" has invalid "mount" config. "path" and "subdomain" must be strings when provided.`,
|
|
22886
|
+
serviceName: name
|
|
22887
|
+
}
|
|
22888
|
+
};
|
|
22889
|
+
}
|
|
22890
|
+
if (typeof mountPath !== "string" && typeof mountSubdomain !== "string") {
|
|
22891
|
+
return {
|
|
22892
|
+
error: {
|
|
22893
|
+
code: "INVALID_MOUNT",
|
|
22894
|
+
message: `Service "${name}" has invalid "mount" config. Specify at least one of "mount.path" or "mount.subdomain".`,
|
|
22895
|
+
serviceName: name
|
|
22896
|
+
}
|
|
22897
|
+
};
|
|
22898
|
+
}
|
|
22899
|
+
return {
|
|
22900
|
+
routing: {
|
|
22901
|
+
routePrefix: mountPath,
|
|
22902
|
+
subdomain: mountSubdomain,
|
|
22903
|
+
routePrefixConfigured: typeof mountPath === "string"
|
|
22904
|
+
}
|
|
22905
|
+
};
|
|
22906
|
+
}
|
|
22829
22907
|
function validateServiceConfig(name, config) {
|
|
22830
22908
|
if (!SERVICE_NAME_REGEX.test(name)) {
|
|
22831
22909
|
return {
|
|
@@ -22842,40 +22920,46 @@ var require_resolve = __commonJS({
|
|
|
22842
22920
|
};
|
|
22843
22921
|
}
|
|
22844
22922
|
const serviceType = config.type || "web";
|
|
22845
|
-
const
|
|
22846
|
-
|
|
22847
|
-
|
|
22923
|
+
const routingResult = resolveServiceRoutingConfig(name, config);
|
|
22924
|
+
if (routingResult.error) {
|
|
22925
|
+
return routingResult.error;
|
|
22926
|
+
}
|
|
22927
|
+
const configuredRoutePrefix = routingResult.routing?.routePrefix;
|
|
22928
|
+
const configuredSubdomain = routingResult.routing?.subdomain;
|
|
22929
|
+
const hasRoutePrefix = typeof configuredRoutePrefix === "string";
|
|
22930
|
+
const hasSubdomain = typeof configuredSubdomain === "string";
|
|
22931
|
+
if (hasSubdomain && !DNS_LABEL_RE.test(configuredSubdomain)) {
|
|
22848
22932
|
return {
|
|
22849
22933
|
code: "INVALID_SUBDOMAIN",
|
|
22850
|
-
message: `Web service "${name}" has invalid subdomain "${
|
|
22934
|
+
message: `Web service "${name}" has invalid subdomain "${configuredSubdomain}". Use a single DNS label such as "api".`,
|
|
22851
22935
|
serviceName: name
|
|
22852
22936
|
};
|
|
22853
22937
|
}
|
|
22854
22938
|
if (serviceType === "web" && !hasRoutePrefix && !hasSubdomain) {
|
|
22855
22939
|
return {
|
|
22856
22940
|
code: "MISSING_ROUTE_PREFIX",
|
|
22857
|
-
message: `Web service "${name}" must specify at least one of "routePrefix" or "subdomain".`,
|
|
22941
|
+
message: `Web service "${name}" must specify at least one of "mount", "routePrefix", or "subdomain".`,
|
|
22858
22942
|
serviceName: name
|
|
22859
22943
|
};
|
|
22860
22944
|
}
|
|
22861
|
-
if (serviceType === "web" &&
|
|
22945
|
+
if (serviceType === "web" && configuredRoutePrefix && isReservedServiceRoutePrefix(configuredRoutePrefix)) {
|
|
22862
22946
|
return {
|
|
22863
22947
|
code: "RESERVED_ROUTE_PREFIX",
|
|
22864
|
-
message: `Web service "${name}" cannot use routePrefix "${
|
|
22948
|
+
message: `Web service "${name}" cannot use routePrefix "${configuredRoutePrefix}". The "${import_utils.INTERNAL_SERVICE_PREFIX}" prefix is reserved for internal services routing.`,
|
|
22865
22949
|
serviceName: name
|
|
22866
22950
|
};
|
|
22867
22951
|
}
|
|
22868
|
-
if ((serviceType === "worker" || serviceType === "cron") &&
|
|
22952
|
+
if ((serviceType === "worker" || serviceType === "cron") && configuredRoutePrefix) {
|
|
22869
22953
|
return {
|
|
22870
22954
|
code: "INVALID_ROUTE_PREFIX",
|
|
22871
|
-
message: `${serviceType === "worker" ? "Worker" : "Cron"} service "${name}" cannot have "routePrefix". Only web services should specify
|
|
22955
|
+
message: `${serviceType === "worker" ? "Worker" : "Cron"} service "${name}" cannot have "routePrefix" or "mount". Only web services should specify path-based routing.`,
|
|
22872
22956
|
serviceName: name
|
|
22873
22957
|
};
|
|
22874
22958
|
}
|
|
22875
22959
|
if ((serviceType === "worker" || serviceType === "cron") && hasSubdomain) {
|
|
22876
22960
|
return {
|
|
22877
22961
|
code: "INVALID_HOST_ROUTING_CONFIG",
|
|
22878
|
-
message: `${serviceType === "worker" ? "Worker" : "Cron"} service "${name}" cannot have "subdomain". Only web services should specify subdomain routing.`,
|
|
22962
|
+
message: `${serviceType === "worker" ? "Worker" : "Cron"} service "${name}" cannot have "subdomain" or "mount.subdomain". Only web services should specify subdomain routing.`,
|
|
22879
22963
|
serviceName: name
|
|
22880
22964
|
};
|
|
22881
22965
|
}
|
|
@@ -22967,6 +23051,13 @@ var require_resolve = __commonJS({
|
|
|
22967
23051
|
const type = config.type || "web";
|
|
22968
23052
|
const rawEntrypoint = config.entrypoint;
|
|
22969
23053
|
const moduleAttrParsed = typeof rawEntrypoint === "string" && type === "cron" ? parsePyModuleAttrEntrypoint(rawEntrypoint) : null;
|
|
23054
|
+
const routingResult = resolveServiceRoutingConfig(name, config);
|
|
23055
|
+
if (routingResult.error) {
|
|
23056
|
+
throw new Error(routingResult.error.message);
|
|
23057
|
+
}
|
|
23058
|
+
const configuredRoutePrefix = routingResult.routing?.routePrefix;
|
|
23059
|
+
const configuredSubdomain = routingResult.routing?.subdomain;
|
|
23060
|
+
const routePrefixWasConfigured = routingResult.routing?.routePrefixConfigured ?? false;
|
|
22970
23061
|
let resolvedEntrypointPath = resolvedEntrypoint;
|
|
22971
23062
|
if (!resolvedEntrypointPath && typeof rawEntrypoint === "string") {
|
|
22972
23063
|
const entrypointToResolve = moduleAttrParsed ? moduleAttrParsed.filePath : rawEntrypoint;
|
|
@@ -23036,10 +23127,10 @@ var require_resolve = __commonJS({
|
|
|
23036
23127
|
}
|
|
23037
23128
|
builderSrc = resolvedEntrypointFile;
|
|
23038
23129
|
}
|
|
23039
|
-
const normalizedSubdomain = type === "web" && typeof
|
|
23130
|
+
const normalizedSubdomain = type === "web" && typeof configuredSubdomain === "string" ? configuredSubdomain.toLowerCase() : void 0;
|
|
23040
23131
|
const defaultRoutePrefix = type === "web" && normalizedSubdomain ? `/_/${name}` : void 0;
|
|
23041
|
-
const routePrefix = type === "web" && (
|
|
23042
|
-
const resolvedRoutePrefixSource = type === "web" && typeof routePrefix === "string" ?
|
|
23132
|
+
const routePrefix = type === "web" && (configuredRoutePrefix || defaultRoutePrefix) ? (configuredRoutePrefix || defaultRoutePrefix).startsWith("/") ? configuredRoutePrefix || defaultRoutePrefix : `/${configuredRoutePrefix || defaultRoutePrefix}` : void 0;
|
|
23133
|
+
const resolvedRoutePrefixSource = type === "web" && typeof routePrefix === "string" ? routePrefixWasConfigured ? routePrefixSource : "generated" : void 0;
|
|
23043
23134
|
const isRoot = workspace === ".";
|
|
23044
23135
|
if (!isRoot) {
|
|
23045
23136
|
builderSrc = import_path7.posix.join(workspace, builderSrc);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/static-build",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.12",
|
|
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/
|
|
17
|
+
"@vercel/static-config": "3.2.0",
|
|
18
18
|
"@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
|
|
19
|
-
"@vercel/
|
|
19
|
+
"@vercel/gatsby-plugin-vercel-builder": "2.1.12"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/aws-lambda": "8.10.64",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"rc9": "1.2.0",
|
|
39
39
|
"semver": "7.5.2",
|
|
40
40
|
"tree-kill": "1.2.2",
|
|
41
|
-
"@vercel/
|
|
41
|
+
"@vercel/fs-detectors": "5.15.2",
|
|
42
42
|
"@vercel/frameworks": "3.24.0",
|
|
43
|
-
"@vercel/fs-detectors": "5.15.1",
|
|
44
43
|
"@vercel/routing-utils": "6.1.1",
|
|
45
|
-
"@vercel/error-utils": "2.0.3"
|
|
44
|
+
"@vercel/error-utils": "2.0.3",
|
|
45
|
+
"@vercel/build-utils": "13.14.2"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "node ../../utils/build-builder.mjs",
|