@vercel/static-build 2.9.25 → 2.9.26
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 +99 -8
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -22856,7 +22856,7 @@ var require_resolve = __commonJS({
|
|
|
22856
22856
|
}
|
|
22857
22857
|
var SERVICE_NAME_REGEX = /^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;
|
|
22858
22858
|
var DNS_LABEL_RE = /^(?!-)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
|
|
22859
|
-
var
|
|
22859
|
+
var ENV_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
22860
22860
|
var ENTRYPOINT_REQUIRED_RUNTIMES = /* @__PURE__ */ new Set([
|
|
22861
22861
|
"node",
|
|
22862
22862
|
"python",
|
|
@@ -23235,14 +23235,46 @@ var require_resolve = __commonJS({
|
|
|
23235
23235
|
};
|
|
23236
23236
|
}
|
|
23237
23237
|
}
|
|
23238
|
-
if (config.
|
|
23239
|
-
if (
|
|
23238
|
+
if (config.env !== void 0) {
|
|
23239
|
+
if (typeof config.env !== "object" || Array.isArray(config.env)) {
|
|
23240
23240
|
return {
|
|
23241
|
-
code: "
|
|
23242
|
-
message: `Service "${name}" has invalid
|
|
23241
|
+
code: "INVALID_ENV_VARS",
|
|
23242
|
+
message: `Service "${name}" has invalid "env". Must be an object keyed by environment variable name.`,
|
|
23243
23243
|
serviceName: name
|
|
23244
23244
|
};
|
|
23245
23245
|
}
|
|
23246
|
+
for (const [envVarName, envVar] of Object.entries(config.env)) {
|
|
23247
|
+
if (!ENV_VAR_NAME_RE.test(envVarName)) {
|
|
23248
|
+
return {
|
|
23249
|
+
code: "INVALID_ENV_VAR_NAME",
|
|
23250
|
+
message: `Service "${name}" has invalid env key "${envVarName}". Must match /^[A-Za-z_][A-Za-z0-9_]*$/.`,
|
|
23251
|
+
serviceName: name
|
|
23252
|
+
};
|
|
23253
|
+
}
|
|
23254
|
+
if (!envVar || typeof envVar !== "object" || Array.isArray(envVar)) {
|
|
23255
|
+
return {
|
|
23256
|
+
code: "INVALID_ENV_VAR",
|
|
23257
|
+
message: `Service "${name}" has invalid env["${envVarName}"]. Must be an object with a "type" discriminator.`,
|
|
23258
|
+
serviceName: name
|
|
23259
|
+
};
|
|
23260
|
+
}
|
|
23261
|
+
const envVarType = envVar.type;
|
|
23262
|
+
if (envVarType !== "service-ref") {
|
|
23263
|
+
return {
|
|
23264
|
+
code: "INVALID_ENV_VAR_TYPE",
|
|
23265
|
+
message: `Service "${name}" env["${envVarName}"] has unknown type "${envVarType}".`,
|
|
23266
|
+
serviceName: name
|
|
23267
|
+
};
|
|
23268
|
+
}
|
|
23269
|
+
const refService = envVar.service;
|
|
23270
|
+
if (typeof refService !== "string" || refService.length === 0) {
|
|
23271
|
+
return {
|
|
23272
|
+
code: "INVALID_ENV_VAR_REF",
|
|
23273
|
+
message: `Service "${name}" env["${envVarName}"] must specify "service" as a non-empty string.`,
|
|
23274
|
+
serviceName: name
|
|
23275
|
+
};
|
|
23276
|
+
}
|
|
23277
|
+
}
|
|
23246
23278
|
}
|
|
23247
23279
|
if (config.runtime && !(config.runtime in import_types.RUNTIME_BUILDERS)) {
|
|
23248
23280
|
return {
|
|
@@ -23466,7 +23498,7 @@ var require_resolve = __commonJS({
|
|
|
23466
23498
|
schedule: config.schedule,
|
|
23467
23499
|
handlerFunction: moduleAttrParsed?.attrName,
|
|
23468
23500
|
topics,
|
|
23469
|
-
|
|
23501
|
+
env: config.env
|
|
23470
23502
|
};
|
|
23471
23503
|
}
|
|
23472
23504
|
async function resolveAllConfiguredServices(services, fs5, routePrefixSource = "configured", options = {}) {
|
|
@@ -23614,8 +23646,49 @@ var require_resolve = __commonJS({
|
|
|
23614
23646
|
}
|
|
23615
23647
|
resolved.push(service);
|
|
23616
23648
|
}
|
|
23649
|
+
const servicesByName = new Map(resolved.map((s) => [s.name, s]));
|
|
23650
|
+
for (const service of resolved) {
|
|
23651
|
+
if (!service.env)
|
|
23652
|
+
continue;
|
|
23653
|
+
validateEnvRefs(
|
|
23654
|
+
service.env,
|
|
23655
|
+
`Service "${service.name}" env`,
|
|
23656
|
+
servicesByName,
|
|
23657
|
+
errors,
|
|
23658
|
+
service.name
|
|
23659
|
+
);
|
|
23660
|
+
}
|
|
23661
|
+
if (options.rootEnv) {
|
|
23662
|
+
validateEnvRefs(options.rootEnv, "env", servicesByName, errors);
|
|
23663
|
+
for (const service of resolved) {
|
|
23664
|
+
service.env = { ...options.rootEnv, ...service.env ?? {} };
|
|
23665
|
+
}
|
|
23666
|
+
}
|
|
23617
23667
|
return { services: resolved, errors };
|
|
23618
23668
|
}
|
|
23669
|
+
function validateEnvRefs(env, pathPrefix, servicesByName, errors, serviceName) {
|
|
23670
|
+
for (const [envVarName, envVar] of Object.entries(env)) {
|
|
23671
|
+
if (envVar.type !== "service-ref")
|
|
23672
|
+
continue;
|
|
23673
|
+
const refName = envVar.service;
|
|
23674
|
+
const target = servicesByName.get(refName);
|
|
23675
|
+
if (!target) {
|
|
23676
|
+
errors.push({
|
|
23677
|
+
code: "UNKNOWN_SERVICE_REF",
|
|
23678
|
+
message: `${pathPrefix}["${envVarName}"] references unknown service "${refName}".`,
|
|
23679
|
+
...serviceName ? { serviceName } : {}
|
|
23680
|
+
});
|
|
23681
|
+
continue;
|
|
23682
|
+
}
|
|
23683
|
+
if (target.type !== "web") {
|
|
23684
|
+
errors.push({
|
|
23685
|
+
code: "INVALID_SERVICE_REF_TYPE",
|
|
23686
|
+
message: `${pathPrefix}["${envVarName}"] references service "${refName}" which is a ${target.type} service and has no URL. Only web services can be referenced.`,
|
|
23687
|
+
...serviceName ? { serviceName } : {}
|
|
23688
|
+
});
|
|
23689
|
+
}
|
|
23690
|
+
}
|
|
23691
|
+
}
|
|
23619
23692
|
}
|
|
23620
23693
|
});
|
|
23621
23694
|
|
|
@@ -24181,10 +24254,17 @@ var require_detect_services = __commonJS({
|
|
|
24181
24254
|
workers: []
|
|
24182
24255
|
};
|
|
24183
24256
|
}
|
|
24257
|
+
function isEnvVars(env) {
|
|
24258
|
+
if (!env)
|
|
24259
|
+
return false;
|
|
24260
|
+
const first = Object.values(env)[0];
|
|
24261
|
+
return typeof first === "object" && first !== null;
|
|
24262
|
+
}
|
|
24184
24263
|
function withResolvedResult(resolved, inferred = null) {
|
|
24185
24264
|
return {
|
|
24186
24265
|
services: resolved.services,
|
|
24187
24266
|
source: resolved.source,
|
|
24267
|
+
useImplicitEnvInjection: resolved.useImplicitEnvInjection,
|
|
24188
24268
|
routes: resolved.routes,
|
|
24189
24269
|
errors: resolved.errors,
|
|
24190
24270
|
warnings: resolved.warnings,
|
|
@@ -24220,6 +24300,7 @@ var require_detect_services = __commonJS({
|
|
|
24220
24300
|
return withResolvedResult({
|
|
24221
24301
|
services: [],
|
|
24222
24302
|
source: "configured",
|
|
24303
|
+
useImplicitEnvInjection: true,
|
|
24223
24304
|
routes: emptyRoutes(),
|
|
24224
24305
|
errors: [configError],
|
|
24225
24306
|
warnings: []
|
|
@@ -24234,6 +24315,7 @@ var require_detect_services = __commonJS({
|
|
|
24234
24315
|
return withResolvedResult({
|
|
24235
24316
|
services: [],
|
|
24236
24317
|
source: "auto-detected",
|
|
24318
|
+
useImplicitEnvInjection: true,
|
|
24237
24319
|
routes: emptyRoutes(),
|
|
24238
24320
|
errors: railwayResult.errors,
|
|
24239
24321
|
warnings: railwayResult.warnings
|
|
@@ -24255,6 +24337,7 @@ var require_detect_services = __commonJS({
|
|
|
24255
24337
|
{
|
|
24256
24338
|
services: [],
|
|
24257
24339
|
source: "auto-detected",
|
|
24340
|
+
useImplicitEnvInjection: true,
|
|
24258
24341
|
routes: emptyRoutes(),
|
|
24259
24342
|
errors: result2.errors,
|
|
24260
24343
|
warnings: railwayResult.warnings
|
|
@@ -24273,6 +24356,7 @@ var require_detect_services = __commonJS({
|
|
|
24273
24356
|
const resolved = {
|
|
24274
24357
|
services: result2.services,
|
|
24275
24358
|
source: "auto-detected",
|
|
24359
|
+
useImplicitEnvInjection: true,
|
|
24276
24360
|
routes: routes2,
|
|
24277
24361
|
errors: result2.errors,
|
|
24278
24362
|
warnings: []
|
|
@@ -24291,6 +24375,7 @@ var require_detect_services = __commonJS({
|
|
|
24291
24375
|
return withResolvedResult({
|
|
24292
24376
|
services: [],
|
|
24293
24377
|
source: "auto-detected",
|
|
24378
|
+
useImplicitEnvInjection: true,
|
|
24294
24379
|
routes: emptyRoutes(),
|
|
24295
24380
|
errors: autoResult.errors,
|
|
24296
24381
|
warnings: []
|
|
@@ -24299,6 +24384,7 @@ var require_detect_services = __commonJS({
|
|
|
24299
24384
|
return withResolvedResult({
|
|
24300
24385
|
services: [],
|
|
24301
24386
|
source: "auto-detected",
|
|
24387
|
+
useImplicitEnvInjection: true,
|
|
24302
24388
|
routes: emptyRoutes(),
|
|
24303
24389
|
errors: [
|
|
24304
24390
|
{
|
|
@@ -24316,13 +24402,17 @@ var require_detect_services = __commonJS({
|
|
|
24316
24402
|
{
|
|
24317
24403
|
requireFileEntrypointForBackendRuntimes: Boolean(
|
|
24318
24404
|
hasNonEmptyPublicServicesConfig
|
|
24319
|
-
)
|
|
24405
|
+
),
|
|
24406
|
+
rootEnv: isEnvVars(vercelConfig?.env) ? vercelConfig?.env : void 0
|
|
24320
24407
|
}
|
|
24321
24408
|
);
|
|
24322
24409
|
const routes = generateServicesRoutes2(result.services);
|
|
24323
24410
|
return withResolvedResult({
|
|
24324
24411
|
services: result.services,
|
|
24325
24412
|
source: "configured",
|
|
24413
|
+
// GA `services` opts into explicit `env`; experimentalServices keeps
|
|
24414
|
+
// the legacy `{NAME}_URL` injection.
|
|
24415
|
+
useImplicitEnvInjection: !hasNonEmptyPublicServicesConfig,
|
|
24326
24416
|
routes,
|
|
24327
24417
|
errors: result.errors,
|
|
24328
24418
|
warnings: []
|
|
@@ -24772,7 +24862,8 @@ var require_get_services_builders = __commonJS({
|
|
|
24772
24862
|
...result.routes.crons
|
|
24773
24863
|
] : null,
|
|
24774
24864
|
errorRoutes: [],
|
|
24775
|
-
services: result.services
|
|
24865
|
+
services: result.services,
|
|
24866
|
+
useImplicitEnvInjection: result.useImplicitEnvInjection
|
|
24776
24867
|
};
|
|
24777
24868
|
}
|
|
24778
24869
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/static-build",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.26",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/build-step",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"ts-morph": "12.0.0",
|
|
17
|
-
"@vercel/gatsby-plugin-vercel-builder": "2.2.3",
|
|
18
17
|
"@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
|
|
18
|
+
"@vercel/gatsby-plugin-vercel-builder": "2.2.4",
|
|
19
19
|
"@vercel/static-config": "3.3.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"semver": "7.5.2",
|
|
38
38
|
"tree-kill": "1.2.2",
|
|
39
39
|
"vitest": "2.0.3",
|
|
40
|
-
"@vercel/build-utils": "13.
|
|
41
|
-
"@vercel/error-utils": "2.1.0",
|
|
40
|
+
"@vercel/build-utils": "13.24.0",
|
|
42
41
|
"@vercel/frameworks": "3.26.0",
|
|
43
|
-
"@vercel/fs-detectors": "6.
|
|
42
|
+
"@vercel/fs-detectors": "6.3.0",
|
|
43
|
+
"@vercel/error-utils": "2.1.0",
|
|
44
44
|
"@vercel/routing-utils": "6.2.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|