@vercel/static-build 2.11.0 → 2.11.2

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.
Files changed (2) hide show
  1. package/dist/index.js +139 -12
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -21767,7 +21767,8 @@ var require_types3 = __commonJS({
21767
21767
  python: "@vercel/python",
21768
21768
  go: "@vercel/go",
21769
21769
  rust: "@vercel/rust",
21770
- ruby: "@vercel/ruby"
21770
+ ruby: "@vercel/ruby",
21771
+ container: "@vercel/container"
21771
21772
  };
21772
21773
  var RUNTIME_MANIFESTS = {
21773
21774
  node: ["package.json"],
@@ -23253,6 +23254,12 @@ var require_resolve = __commonJS({
23253
23254
  "python",
23254
23255
  "go"
23255
23256
  ]);
23257
+ function isContainerRuntime(config) {
23258
+ return config.runtime === "container";
23259
+ }
23260
+ function normalizeContainerCommand(command) {
23261
+ return Array.isArray(command) ? command : [command];
23262
+ }
23256
23263
  async function getServiceFs(fs5, serviceName, root) {
23257
23264
  if (!root) {
23258
23265
  return { fs: fs5 };
@@ -23338,6 +23345,10 @@ var require_resolve = __commonJS({
23338
23345
  }
23339
23346
  };
23340
23347
  }
23348
+ function isDockerfileEntrypoint(entrypoint) {
23349
+ const base = import_path7.posix.basename(entrypoint).toLowerCase();
23350
+ return base === "dockerfile" || base === "containerfile" || base.endsWith(".dockerfile");
23351
+ }
23341
23352
  function toWorkspaceRelativeEntrypoint(entrypoint, workspace) {
23342
23353
  const normalizedEntrypoint = import_path7.posix.normalize(entrypoint);
23343
23354
  if (workspace === ".") {
@@ -23716,6 +23727,13 @@ var require_resolve = __commonJS({
23716
23727
  serviceName: name
23717
23728
  };
23718
23729
  }
23730
+ if (config.command !== void 0 && !isContainerRuntime(config)) {
23731
+ return {
23732
+ code: "INVALID_COMMAND",
23733
+ message: `Service "${name}" can only specify "command" when using runtime "container".`,
23734
+ serviceName: name
23735
+ };
23736
+ }
23719
23737
  return null;
23720
23738
  }
23721
23739
  function validateServiceEntrypoint(name, config, resolvedEntrypoint) {
@@ -23756,8 +23774,11 @@ var require_resolve = __commonJS({
23756
23774
  const configuredRoutePrefix = routingResult.routing?.routePrefix;
23757
23775
  const configuredSubdomain = routingResult.routing?.subdomain;
23758
23776
  const routePrefixWasConfigured = routingResult.routing?.routePrefixConfigured ?? false;
23777
+ const containerEntrypoint = isContainerRuntime(config) && typeof rawEntrypoint === "string" ? rawEntrypoint : void 0;
23778
+ const containerDockerfile = containerEntrypoint && isDockerfileEntrypoint(containerEntrypoint) ? import_path7.posix.normalize(containerEntrypoint) : void 0;
23779
+ const containerImage = containerEntrypoint && !containerDockerfile ? containerEntrypoint : void 0;
23759
23780
  let resolvedEntrypointPath = resolvedEntrypoint;
23760
- if (!resolvedEntrypointPath && typeof rawEntrypoint === "string") {
23781
+ if (!containerEntrypoint && !resolvedEntrypointPath && typeof rawEntrypoint === "string") {
23761
23782
  const entrypointToResolve = moduleAttrParsed ? moduleAttrParsed.filePath : rawEntrypoint;
23762
23783
  const resolved = await resolveEntrypointPath({
23763
23784
  fs: serviceFs,
@@ -23766,7 +23787,7 @@ var require_resolve = __commonJS({
23766
23787
  });
23767
23788
  resolvedEntrypointPath = resolved.entrypoint;
23768
23789
  }
23769
- if (typeof rawEntrypoint === "string" && !resolvedEntrypointPath) {
23790
+ if (!containerEntrypoint && typeof rawEntrypoint === "string" && !resolvedEntrypointPath) {
23770
23791
  throw new Error(
23771
23792
  `Failed to resolve entrypoint "${rawEntrypoint}" for service "${name}".`
23772
23793
  );
@@ -23830,7 +23851,7 @@ var require_resolve = __commonJS({
23830
23851
  } else {
23831
23852
  builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
23832
23853
  }
23833
- builderSrc = resolvedEntrypointFile;
23854
+ builderSrc = inferredRuntime === "container" && typeof containerEntrypoint === "string" ? containerEntrypoint : resolvedEntrypointFile;
23834
23855
  }
23835
23856
  const normalizedSubdomain = type === "web" && typeof configuredSubdomain === "string" ? configuredSubdomain.toLowerCase() : void 0;
23836
23857
  const defaultRoutePrefix = type === "web" && normalizedSubdomain ? `/_/${name}` : void 0;
@@ -23864,6 +23885,12 @@ var require_resolve = __commonJS({
23864
23885
  if (config.framework) {
23865
23886
  builderConfig.framework = config.framework;
23866
23887
  }
23888
+ if (containerImage) {
23889
+ builderConfig.handler = containerImage;
23890
+ }
23891
+ if (config.command !== void 0) {
23892
+ builderConfig.command = normalizeContainerCommand(config.command);
23893
+ }
23867
23894
  if (moduleAttrParsed) {
23868
23895
  builderConfig.handlerFunction = moduleAttrParsed.attrName;
23869
23896
  }
@@ -23874,7 +23901,7 @@ var require_resolve = __commonJS({
23874
23901
  trigger,
23875
23902
  group,
23876
23903
  workspace,
23877
- entrypoint: resolvedEntrypointFile,
23904
+ entrypoint: containerImage ?? containerDockerfile ?? resolvedEntrypointFile,
23878
23905
  routePrefix,
23879
23906
  routePrefixSource: resolvedRoutePrefixSource,
23880
23907
  subdomain: normalizedSubdomain,
@@ -23913,7 +23940,7 @@ var require_resolve = __commonJS({
23913
23940
  }
23914
23941
  const serviceFs = serviceFsResult.fs;
23915
23942
  let resolvedEntrypoint;
23916
- if (typeof serviceConfig.entrypoint === "string") {
23943
+ if (typeof serviceConfig.entrypoint === "string" && !isContainerRuntime(serviceConfig)) {
23917
23944
  const moduleAttr = parsePyModuleAttrEntrypoint(serviceConfig.entrypoint);
23918
23945
  const entrypointToResolve = moduleAttr?.filePath ?? serviceConfig.entrypoint;
23919
23946
  const resolvedPath = await resolveEntrypointPath({
@@ -24110,6 +24137,67 @@ var require_resolve_v2 = __commonJS({
24110
24137
  var import_utils = require_utils4();
24111
24138
  var frameworksBySlug = new Map(import_frameworks2.frameworkList.map((f) => [f.slug, f]));
24112
24139
  var SERVICE_NAME_REGEX = /^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;
24140
+ function isDockerfileEntrypoint(entrypoint) {
24141
+ const base = import_path7.posix.basename(entrypoint).toLowerCase();
24142
+ return base === "dockerfile" || base === "containerfile" || base.endsWith(".dockerfile");
24143
+ }
24144
+ function normalizeContainerCommand(command) {
24145
+ if (command === void 0) {
24146
+ return void 0;
24147
+ }
24148
+ return Array.isArray(command) ? command : [command];
24149
+ }
24150
+ function resolveContainerServiceV2(name, config, normalizedRoot) {
24151
+ const isRoot = normalizedRoot === ".";
24152
+ const entrypoint = config.entrypoint;
24153
+ const dockerfile = typeof entrypoint === "string" && isDockerfileEntrypoint(entrypoint) ? import_path7.posix.normalize(entrypoint) : void 0;
24154
+ const image = typeof entrypoint === "string" && !dockerfile ? entrypoint : void 0;
24155
+ if (!dockerfile && !image) {
24156
+ return {
24157
+ error: {
24158
+ code: "MISSING_SERVICE_CONFIG",
24159
+ message: `Container service "${name}" must specify an "entrypoint": a Dockerfile path to build, or a prebuilt OCI image reference.`,
24160
+ serviceName: name
24161
+ }
24162
+ };
24163
+ }
24164
+ const localSrc = dockerfile ?? image ?? "Dockerfile";
24165
+ const builderSrc = isRoot ? localSrc : import_path7.posix.join(normalizedRoot, localSrc);
24166
+ const builderConfig = { zeroConfig: true };
24167
+ if (!isRoot) {
24168
+ builderConfig.workspace = normalizedRoot;
24169
+ }
24170
+ if (image) {
24171
+ builderConfig.handler = image;
24172
+ }
24173
+ const command = normalizeContainerCommand(config.command);
24174
+ if (command) {
24175
+ builderConfig.command = command;
24176
+ }
24177
+ return {
24178
+ service: {
24179
+ schema: "experimentalServicesV2",
24180
+ name,
24181
+ root: normalizedRoot,
24182
+ runtime: "container",
24183
+ entrypoint: image ?? dockerfile,
24184
+ command,
24185
+ builder: {
24186
+ src: builderSrc,
24187
+ use: "@vercel/container",
24188
+ config: builderConfig
24189
+ },
24190
+ bindings: config.bindings,
24191
+ functions: config.functions,
24192
+ headers: config.headers,
24193
+ redirects: config.redirects,
24194
+ rewrites: config.rewrites,
24195
+ routes: config.routes,
24196
+ cleanUrls: config.cleanUrls,
24197
+ trailingSlash: config.trailingSlash
24198
+ }
24199
+ };
24200
+ }
24113
24201
  function validateServiceConfigV22(name, config) {
24114
24202
  if (!SERVICE_NAME_REGEX.test(name)) {
24115
24203
  return {
@@ -24171,7 +24259,8 @@ var require_resolve_v2 = __commonJS({
24171
24259
  };
24172
24260
  }
24173
24261
  }
24174
- if (!config.framework && !config.entrypoint) {
24262
+ const isContainer = config.runtime === "container";
24263
+ if (!config.framework && !config.entrypoint && !isContainer) {
24175
24264
  return {
24176
24265
  code: "MISSING_SERVICE_CONFIG",
24177
24266
  message: `Service "${name}" must specify "framework" or "entrypoint".`,
@@ -24182,6 +24271,10 @@ var require_resolve_v2 = __commonJS({
24182
24271
  }
24183
24272
  async function resolveConfiguredServiceV22(name, config, fs5) {
24184
24273
  const normalizedRoot = (0, import_utils.stripTrailingSlash)(import_path7.posix.normalize(config.root));
24274
+ const isContainer = config.runtime === "container" || typeof config.entrypoint === "string" && isDockerfileEntrypoint(config.entrypoint);
24275
+ if (isContainer) {
24276
+ return resolveContainerServiceV2(name, config, normalizedRoot);
24277
+ }
24185
24278
  const serviceFsResult = normalizedRoot === "." ? { fs: fs5 } : await (0, import_resolve.getServiceFs)(fs5, name, normalizedRoot);
24186
24279
  if (serviceFsResult.error) {
24187
24280
  return { error: serviceFsResult.error };
@@ -28308,8 +28401,23 @@ var require_detect_services = __commonJS({
28308
28401
  warnings: []
28309
28402
  });
28310
28403
  }
28404
+ if (vercelConfig?.services != null && vercelConfig.experimentalServicesV2 != null) {
28405
+ return withResolvedResult({
28406
+ services: [],
28407
+ source: "configured",
28408
+ useImplicitEnvInjection: false,
28409
+ routes: emptyRoutes(),
28410
+ errors: [
28411
+ {
28412
+ code: "SERVICES_AND_EXPERIMENTAL_SERVICES_V2",
28413
+ message: "The `services` property cannot be used in conjunction with its deprecated alias `experimentalServicesV2`. Please use only `services`."
28414
+ }
28415
+ ],
28416
+ warnings: []
28417
+ });
28418
+ }
28311
28419
  const hasProvidedConfiguredServices = providedConfiguredServices && Object.keys(providedConfiguredServices).length > 0;
28312
- const experimentalServicesV2 = hasProvidedConfiguredServices && providedConfiguredServicesType === "experimentalServicesV2" ? providedConfiguredServices : hasProvidedConfiguredServices ? void 0 : vercelConfig?.experimentalServicesV2;
28420
+ const experimentalServicesV2 = hasProvidedConfiguredServices && (providedConfiguredServicesType === "services" || providedConfiguredServicesType === "experimentalServicesV2") ? providedConfiguredServices : hasProvidedConfiguredServices ? void 0 : vercelConfig?.services ?? vercelConfig?.experimentalServicesV2;
28313
28421
  if (experimentalServicesV2 && Object.keys(experimentalServicesV2).length > 0) {
28314
28422
  const result2 = await (0, import_resolve_v2.resolveAllConfiguredServicesV2)(
28315
28423
  experimentalServicesV2,
@@ -28488,11 +28596,12 @@ var require_detect_services = __commonJS({
28488
28596
  }
28489
28597
  } else if (service.runtime) {
28490
28598
  const functionPath = (0, import_utils.getInternalServiceFunctionPath)(service.name);
28599
+ const check = service.runtime === "container" ? void 0 : true;
28491
28600
  if (routePrefix === "/") {
28492
28601
  defaults.push({
28493
28602
  src: (0, import_routing_utils.scopeRouteSourceToOwnership)("^/(.*)$", ownershipGuard),
28494
28603
  dest: functionPath,
28495
- check: true
28604
+ ...check ? { check } : {}
28496
28605
  });
28497
28606
  } else {
28498
28607
  rewrites.push({
@@ -28501,7 +28610,7 @@ var require_detect_services = __commonJS({
28501
28610
  ownershipGuard
28502
28611
  ),
28503
28612
  dest: functionPath,
28504
- check: true
28613
+ ...check ? { check } : {}
28505
28614
  });
28506
28615
  }
28507
28616
  }
@@ -29009,12 +29118,30 @@ var require_detect_builders = __commonJS({
29009
29118
  async function detectBuilders2(files, pkg, options = {}) {
29010
29119
  const {
29011
29120
  experimentalServices: experimentalServicesV1,
29121
+ services,
29012
29122
  experimentalServicesV2,
29013
29123
  projectSettings = {}
29014
29124
  } = options;
29125
+ if (services != null && experimentalServicesV2 != null) {
29126
+ return {
29127
+ builders: null,
29128
+ errors: [
29129
+ {
29130
+ code: "SERVICES_AND_EXPERIMENTAL_SERVICES_V2",
29131
+ message: "The `services` option cannot be used in conjunction with its deprecated alias `experimentalServicesV2`. Please use only `services`."
29132
+ }
29133
+ ],
29134
+ warnings: [],
29135
+ defaultRoutes: null,
29136
+ redirectRoutes: null,
29137
+ rewriteRoutes: null,
29138
+ errorRoutes: null
29139
+ };
29140
+ }
29015
29141
  const { framework } = projectSettings;
29016
- const configuredServices = experimentalServicesV2 ?? experimentalServicesV1;
29017
- const configuredServicesType = experimentalServicesV2 ? "experimentalServicesV2" : "experimentalServices";
29142
+ const servicesConfig = services ?? experimentalServicesV2;
29143
+ const configuredServices = servicesConfig ?? experimentalServicesV1;
29144
+ const configuredServicesType = servicesConfig ? services ? "services" : "experimentalServicesV2" : "experimentalServices";
29018
29145
  const hasServicesConfig = configuredServices != null && typeof configuredServices === "object";
29019
29146
  if (hasServicesConfig || framework === "services") {
29020
29147
  const result = await (0, import_get_services_builders.getServicesBuilders)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -15,8 +15,8 @@
15
15
  "dependencies": {
16
16
  "ts-morph": "12.0.0",
17
17
  "@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
18
- "@vercel/gatsby-plugin-vercel-builder": "2.2.20",
19
- "@vercel/static-config": "3.4.0"
18
+ "@vercel/static-config": "3.4.0",
19
+ "@vercel/gatsby-plugin-vercel-builder": "2.2.22"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/aws-lambda": "8.10.64",
@@ -39,8 +39,8 @@
39
39
  "vitest": "2.0.3",
40
40
  "@vercel/frameworks": "3.29.1",
41
41
  "@vercel/error-utils": "2.2.0",
42
- "@vercel/build-utils": "13.31.0",
43
- "@vercel/fs-detectors": "6.9.2",
42
+ "@vercel/build-utils": "13.32.0",
43
+ "@vercel/fs-detectors": "6.10.0",
44
44
  "@vercel/routing-utils": "6.3.1"
45
45
  },
46
46
  "scripts": {