@vercel/static-build 2.9.36 → 2.9.37

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 +306 -5
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -22855,8 +22855,13 @@ var require_resolve = __commonJS({
22855
22855
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
22856
22856
  var resolve_exports = {};
22857
22857
  __export2(resolve_exports, {
22858
+ detectFrameworkFromWorkspace: () => detectFrameworkFromWorkspace,
22859
+ getServiceFs: () => getServiceFs,
22860
+ inferWorkspaceFromNearestManifest: () => inferWorkspaceFromNearestManifest,
22861
+ parsePyModuleAttrEntrypoint: () => parsePyModuleAttrEntrypoint,
22858
22862
  resolveAllConfiguredServices: () => resolveAllConfiguredServices,
22859
22863
  resolveConfiguredService: () => resolveConfiguredService,
22864
+ resolveEntrypointPath: () => resolveEntrypointPath,
22860
22865
  validateServiceConfig: () => validateServiceConfig,
22861
22866
  validateServiceEntrypoint: () => validateServiceEntrypoint
22862
22867
  });
@@ -23503,6 +23508,7 @@ var require_resolve = __commonJS({
23503
23508
  builderConfig.handlerFunction = moduleAttrParsed.attrName;
23504
23509
  }
23505
23510
  return {
23511
+ schema: "experimentalServices",
23506
23512
  name,
23507
23513
  type,
23508
23514
  trigger,
@@ -23708,6 +23714,270 @@ var require_resolve = __commonJS({
23708
23714
  }
23709
23715
  });
23710
23716
 
23717
+ // ../fs-detectors/dist/services/resolve-v2.js
23718
+ var require_resolve_v2 = __commonJS({
23719
+ "../fs-detectors/dist/services/resolve-v2.js"(exports, module2) {
23720
+ "use strict";
23721
+ var __defProp2 = Object.defineProperty;
23722
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
23723
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
23724
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
23725
+ var __export2 = (target, all) => {
23726
+ for (var name in all)
23727
+ __defProp2(target, name, { get: all[name], enumerable: true });
23728
+ };
23729
+ var __copyProps2 = (to, from, except, desc) => {
23730
+ if (from && typeof from === "object" || typeof from === "function") {
23731
+ for (let key of __getOwnPropNames2(from))
23732
+ if (!__hasOwnProp2.call(to, key) && key !== except)
23733
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
23734
+ }
23735
+ return to;
23736
+ };
23737
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
23738
+ var resolve_v2_exports = {};
23739
+ __export2(resolve_v2_exports, {
23740
+ resolveAllConfiguredServicesV2: () => resolveAllConfiguredServicesV22,
23741
+ resolveConfiguredServiceV2: () => resolveConfiguredServiceV22,
23742
+ validateServiceConfigV2: () => validateServiceConfigV22
23743
+ });
23744
+ module2.exports = __toCommonJS2(resolve_v2_exports);
23745
+ var import_path7 = require("path");
23746
+ var import_build_utils5 = require("@vercel/build-utils");
23747
+ var import_frameworks2 = require_frameworks();
23748
+ var import_types = require_types3();
23749
+ var import_resolve = require_resolve();
23750
+ var import_utils = require_utils4();
23751
+ var frameworksBySlug = new Map(import_frameworks2.frameworkList.map((f) => [f.slug, f]));
23752
+ var SERVICE_NAME_REGEX = /^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;
23753
+ function validateServiceConfigV22(name, config) {
23754
+ if (!SERVICE_NAME_REGEX.test(name)) {
23755
+ return {
23756
+ code: "INVALID_SERVICE_NAME",
23757
+ message: `Service name "${name}" is invalid. Names must start with a letter, end with an alphanumeric character, and contain only alphanumeric characters, hyphens, and underscores.`,
23758
+ serviceName: name
23759
+ };
23760
+ }
23761
+ if (!config || typeof config !== "object") {
23762
+ return {
23763
+ code: "INVALID_SERVICE_CONFIG",
23764
+ message: `Service "${name}" has an invalid configuration. Expected an object.`,
23765
+ serviceName: name
23766
+ };
23767
+ }
23768
+ if (typeof config.root !== "string" || config.root.length === 0) {
23769
+ return {
23770
+ code: "MISSING_ROOT",
23771
+ message: `Service "${name}" must specify a "root".`,
23772
+ serviceName: name
23773
+ };
23774
+ }
23775
+ const normalizedRoot = import_path7.posix.normalize(config.root);
23776
+ if (normalizedRoot.startsWith("/")) {
23777
+ return {
23778
+ code: "INVALID_ROOT",
23779
+ message: `Service "${name}" has invalid "root" "${config.root}". Must be a relative path.`,
23780
+ serviceName: name
23781
+ };
23782
+ }
23783
+ if (normalizedRoot === ".." || normalizedRoot.startsWith("../")) {
23784
+ return {
23785
+ code: "INVALID_ROOT",
23786
+ message: `Service "${name}" has invalid "root" "${config.root}". Must not escape the project root.`,
23787
+ serviceName: name
23788
+ };
23789
+ }
23790
+ if (config.runtime && !(config.runtime in import_types.RUNTIME_BUILDERS)) {
23791
+ return {
23792
+ code: "INVALID_RUNTIME",
23793
+ message: `Service "${name}" has invalid runtime "${config.runtime}".`,
23794
+ serviceName: name
23795
+ };
23796
+ }
23797
+ if (config.framework && !frameworksBySlug.has(config.framework)) {
23798
+ return {
23799
+ code: "INVALID_FRAMEWORK",
23800
+ message: `Service "${name}" has invalid framework "${config.framework}".`,
23801
+ serviceName: name
23802
+ };
23803
+ }
23804
+ if (config.runtime && config.framework) {
23805
+ const frameworkRuntime = (0, import_utils.inferRuntimeFromFramework)(config.framework);
23806
+ if (frameworkRuntime && frameworkRuntime !== config.runtime) {
23807
+ return {
23808
+ code: "RUNTIME_FRAMEWORK_MISMATCH",
23809
+ message: `Service "${name}" has conflicting runtime/framework: runtime "${config.runtime}" is incompatible with framework "${config.framework}" (runtime "${frameworkRuntime}").`,
23810
+ serviceName: name
23811
+ };
23812
+ }
23813
+ }
23814
+ if (!config.framework && !config.entrypoint) {
23815
+ return {
23816
+ code: "MISSING_SERVICE_CONFIG",
23817
+ message: `Service "${name}" must specify "framework" or "entrypoint".`,
23818
+ serviceName: name
23819
+ };
23820
+ }
23821
+ return null;
23822
+ }
23823
+ async function resolveConfiguredServiceV22(name, config, fs5) {
23824
+ const root = config.root;
23825
+ const normalizedRoot = import_path7.posix.normalize(root);
23826
+ const serviceFsResult = normalizedRoot === "." ? { fs: fs5 } : await (0, import_resolve.getServiceFs)(fs5, name, root);
23827
+ if (serviceFsResult.error) {
23828
+ return { error: serviceFsResult.error };
23829
+ }
23830
+ const serviceFs = serviceFsResult.fs;
23831
+ const rawEntrypoint = config.entrypoint;
23832
+ const moduleAttr = typeof rawEntrypoint === "string" ? (0, import_resolve.parsePyModuleAttrEntrypoint)(rawEntrypoint) : null;
23833
+ let normalizedEntrypoint;
23834
+ let entrypointIsDirectory = false;
23835
+ if (typeof rawEntrypoint === "string") {
23836
+ const entrypointToResolve = moduleAttr ? moduleAttr.filePath : rawEntrypoint;
23837
+ const resolved = await (0, import_resolve.resolveEntrypointPath)({
23838
+ fs: serviceFs,
23839
+ serviceName: name,
23840
+ entrypoint: entrypointToResolve
23841
+ });
23842
+ if (resolved.error) {
23843
+ return { error: resolved.error };
23844
+ }
23845
+ normalizedEntrypoint = resolved.entrypoint?.normalized;
23846
+ entrypointIsDirectory = Boolean(resolved.entrypoint?.isDirectory);
23847
+ }
23848
+ const entrypointFile = entrypointIsDirectory || !normalizedEntrypoint ? void 0 : normalizedEntrypoint;
23849
+ const inferredRuntime = (0, import_utils.inferServiceRuntime)({
23850
+ runtime: config.runtime,
23851
+ framework: config.framework,
23852
+ entrypoint: entrypointFile
23853
+ });
23854
+ let framework = config.framework;
23855
+ if (!framework && normalizedEntrypoint) {
23856
+ const workspace = entrypointIsDirectory ? normalizedEntrypoint : import_path7.posix.dirname(normalizedEntrypoint) || ".";
23857
+ const detection = await (0, import_resolve.detectFrameworkFromWorkspace)({
23858
+ fs: serviceFs,
23859
+ workspace,
23860
+ serviceName: name,
23861
+ runtime: inferredRuntime
23862
+ });
23863
+ if (detection.error) {
23864
+ return { error: detection.error };
23865
+ }
23866
+ framework = detection.framework;
23867
+ }
23868
+ if (entrypointIsDirectory && !framework) {
23869
+ return {
23870
+ error: {
23871
+ code: "MISSING_SERVICE_FRAMEWORK",
23872
+ message: `Service "${name}" uses directory entrypoint "${config.entrypoint}" but no framework could be detected. Specify "framework" explicitly or use a file entrypoint.`,
23873
+ serviceName: name
23874
+ }
23875
+ };
23876
+ }
23877
+ const frameworkDefinition = framework ? frameworksBySlug.get(framework) : void 0;
23878
+ let builderUse;
23879
+ let builderSrc;
23880
+ if (framework) {
23881
+ builderUse = (0, import_build_utils5.isNodeBackendFramework)(framework) ? "@vercel/backends" : frameworkDefinition?.useRuntime?.use || "@vercel/static-build";
23882
+ builderSrc = entrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
23883
+ } else {
23884
+ if (!inferredRuntime) {
23885
+ return {
23886
+ error: {
23887
+ code: "MISSING_SERVICE_CONFIG",
23888
+ message: `Service "${name}" must specify "framework" or a runtime-resolvable "entrypoint".`,
23889
+ serviceName: name
23890
+ }
23891
+ };
23892
+ }
23893
+ builderUse = inferredRuntime === "node" ? "@vercel/backends" : (0, import_utils.getBuilderForRuntime)(inferredRuntime);
23894
+ builderSrc = entrypointFile;
23895
+ }
23896
+ const isRoot = normalizedRoot === ".";
23897
+ const projectRelativeSrc = isRoot ? builderSrc : import_path7.posix.join(normalizedRoot, builderSrc);
23898
+ const builderConfig = { zeroConfig: true };
23899
+ if (builderUse === "@vercel/backends") {
23900
+ builderConfig.serviceName = name;
23901
+ }
23902
+ if (framework) {
23903
+ builderConfig.framework = framework;
23904
+ }
23905
+ if (!isRoot) {
23906
+ builderConfig.workspace = normalizedRoot;
23907
+ }
23908
+ if (moduleAttr) {
23909
+ builderConfig.handlerFunction = moduleAttr.attrName;
23910
+ }
23911
+ const runtime = import_types.STATIC_BUILDERS.has(builderUse) ? void 0 : inferredRuntime;
23912
+ return {
23913
+ service: {
23914
+ schema: "experimentalServicesV2",
23915
+ name,
23916
+ root,
23917
+ framework,
23918
+ runtime,
23919
+ entrypoint: entrypointFile,
23920
+ builder: {
23921
+ src: projectRelativeSrc,
23922
+ use: builderUse,
23923
+ config: builderConfig
23924
+ },
23925
+ installCommand: config.installCommand,
23926
+ buildCommand: config.buildCommand,
23927
+ devCommand: config.devCommand,
23928
+ ignoreCommand: config.ignoreCommand,
23929
+ outputDirectory: config.outputDirectory,
23930
+ bindings: config.bindings,
23931
+ functions: config.functions,
23932
+ headers: config.headers,
23933
+ redirects: config.redirects,
23934
+ rewrites: config.rewrites,
23935
+ routes: config.routes,
23936
+ cleanUrls: config.cleanUrls,
23937
+ trailingSlash: config.trailingSlash
23938
+ }
23939
+ };
23940
+ }
23941
+ async function resolveAllConfiguredServicesV22(services, fs5) {
23942
+ const resolved = [];
23943
+ const errors = [];
23944
+ for (const name of Object.keys(services)) {
23945
+ const config = services[name];
23946
+ const validationError = validateServiceConfigV22(name, config);
23947
+ if (validationError) {
23948
+ errors.push(validationError);
23949
+ continue;
23950
+ }
23951
+ const { service, error } = await resolveConfiguredServiceV22(
23952
+ name,
23953
+ config,
23954
+ fs5
23955
+ );
23956
+ if (error) {
23957
+ errors.push(error);
23958
+ continue;
23959
+ }
23960
+ if (service) {
23961
+ resolved.push(service);
23962
+ }
23963
+ }
23964
+ const serviceNames = new Set(Object.keys(services));
23965
+ for (const service of resolved) {
23966
+ for (const binding of service.bindings ?? []) {
23967
+ if (!serviceNames.has(binding.service)) {
23968
+ errors.push({
23969
+ code: "UNKNOWN_SERVICE_BINDING",
23970
+ message: `Service "${service.name}" declares a binding to unknown service "${binding.service}".`,
23971
+ serviceName: service.name
23972
+ });
23973
+ }
23974
+ }
23975
+ }
23976
+ return { services: resolved, errors };
23977
+ }
23978
+ }
23979
+ });
23980
+
23711
23981
  // ../fs-detectors/dist/services/auto-detect.js
23712
23982
  var require_auto_detect = __commonJS({
23713
23983
  "../fs-detectors/dist/services/auto-detect.js"(exports, module2) {
@@ -27599,6 +27869,7 @@ var require_detect_services = __commonJS({
27599
27869
  var import_routing_utils = require_dist7();
27600
27870
  var import_utils = require_utils4();
27601
27871
  var import_resolve = require_resolve();
27872
+ var import_resolve_v2 = require_resolve_v2();
27602
27873
  var import_auto_detect = require_auto_detect();
27603
27874
  var import_detect_railway = require_detect_railway();
27604
27875
  var import_detect_render = require_detect_render();
@@ -27663,7 +27934,8 @@ var require_detect_services = __commonJS({
27663
27934
  fs: fs5,
27664
27935
  workPath,
27665
27936
  detectEntrypoint,
27666
- configuredServices: providedConfiguredServices
27937
+ configuredServices: providedConfiguredServices,
27938
+ configuredServicesType
27667
27939
  } = options;
27668
27940
  const scopedFs = workPath ? fs5.chdir(workPath) : fs5;
27669
27941
  const { config: vercelConfig, error: configError } = await (0, import_utils.readVercelConfig)(scopedFs);
@@ -27678,6 +27950,23 @@ var require_detect_services = __commonJS({
27678
27950
  });
27679
27951
  }
27680
27952
  const hasProvidedConfiguredServices = providedConfiguredServices && Object.keys(providedConfiguredServices).length > 0;
27953
+ const experimentalServicesV2 = hasProvidedConfiguredServices && configuredServicesType === "experimentalServicesV2" ? providedConfiguredServices : hasProvidedConfiguredServices ? void 0 : vercelConfig?.experimentalServicesV2;
27954
+ if (experimentalServicesV2 && Object.keys(experimentalServicesV2).length > 0) {
27955
+ const result2 = await (0, import_resolve_v2.resolveAllConfiguredServicesV2)(
27956
+ experimentalServicesV2,
27957
+ scopedFs
27958
+ );
27959
+ return withResolvedResult({
27960
+ services: result2.services,
27961
+ source: "configured",
27962
+ // V2 uses explicit `bindings`, so no implicit `{NAME}_URL` injection.
27963
+ useImplicitEnvInjection: false,
27964
+ // V2 routes are explicitly carried per-service to output them separately.
27965
+ routes: emptyRoutes(),
27966
+ errors: result2.errors,
27967
+ warnings: []
27968
+ });
27969
+ }
27681
27970
  const configuredServices = hasProvidedConfiguredServices ? providedConfiguredServices : vercelConfig?.experimentalServices;
27682
27971
  const hasConfiguredServices = configuredServices && Object.keys(configuredServices).length > 0;
27683
27972
  if (!hasConfiguredServices) {
@@ -27783,7 +28072,8 @@ var require_detect_services = __commonJS({
27783
28072
  inferred
27784
28073
  );
27785
28074
  }
27786
- function generateServicesRoutes2(services) {
28075
+ function generateServicesRoutes2(allServices) {
28076
+ const services = allServices.filter(import_build_utils5.isExperimentalService);
27787
28077
  const hostRewrites = [];
27788
28078
  const rewrites = [];
27789
28079
  const defaults = [];
@@ -28340,10 +28630,14 @@ var require_detect_builders = __commonJS({
28340
28630
  return publicBuilder ? publicBuilder.src.replace("/**/*", "") : null;
28341
28631
  }
28342
28632
  async function detectBuilders2(files, pkg, options = {}) {
28343
- const { experimentalServices, projectSettings = {} } = options;
28633
+ const {
28634
+ experimentalServices,
28635
+ experimentalServicesV2,
28636
+ projectSettings = {}
28637
+ } = options;
28344
28638
  const { framework } = projectSettings;
28345
- const configuredServices = experimentalServices;
28346
- const configuredServicesType = "experimentalServices";
28639
+ const configuredServices = experimentalServices ?? experimentalServicesV2;
28640
+ const configuredServicesType = experimentalServices ? "experimentalServices" : "experimentalServicesV2";
28347
28641
  const hasServicesConfig = configuredServices != null && typeof configuredServices === "object";
28348
28642
  if (hasServicesConfig || framework === "services") {
28349
28643
  return (0, import_get_services_builders.getServicesBuilders)({
@@ -33671,17 +33965,24 @@ var require_dist8 = __commonJS({
33671
33965
  getServicesBuilders: () => import_get_services_builders.getServicesBuilders,
33672
33966
  getWorkspacePackagePaths: () => import_get_workspace_package_paths.getWorkspacePackagePaths,
33673
33967
  getWorkspaces: () => import_get_workspaces.getWorkspaces,
33968
+ isExperimentalService: () => import_build_utils5.isExperimentalService,
33969
+ isExperimentalServiceV2: () => import_build_utils5.isExperimentalServiceV2,
33674
33970
  isOfficialRuntime: () => import_is_official_runtime.isOfficialRuntime,
33675
33971
  isRouteOwningBuilder: () => import_utils.isRouteOwningBuilder,
33676
33972
  isStaticBuild: () => import_utils.isStaticBuild,
33677
33973
  isStaticRuntime: () => import_is_official_runtime.isStaticRuntime,
33678
33974
  monorepoManagers: () => import_monorepo_managers.monorepoManagers,
33679
33975
  packageManagers: () => import_package_managers.packageManagers,
33976
+ resolveAllConfiguredServicesV2: () => import_resolve_v2.resolveAllConfiguredServicesV2,
33977
+ resolveConfiguredServiceV2: () => import_resolve_v2.resolveConfiguredServiceV2,
33978
+ validateServiceConfigV2: () => import_resolve_v2.validateServiceConfigV2,
33680
33979
  workspaceManagers: () => import_workspace_managers.workspaceManagers
33681
33980
  });
33682
33981
  module2.exports = __toCommonJS2(src_exports2);
33683
33982
  var import_detect_builders = require_detect_builders();
33684
33983
  var import_detect_services = require_detect_services();
33984
+ var import_resolve_v2 = require_resolve_v2();
33985
+ var import_build_utils5 = require("@vercel/build-utils");
33685
33986
  var import_auto_detect = require_auto_detect();
33686
33987
  var import_utils = require_utils4();
33687
33988
  var import_get_services_builders = require_get_services_builders();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "2.9.36",
3
+ "version": "2.9.37",
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.14",
17
18
  "@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
18
- "@vercel/gatsby-plugin-vercel-builder": "2.2.13",
19
19
  "@vercel/static-config": "3.4.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.27.0",
40
+ "@vercel/build-utils": "13.27.1",
41
41
  "@vercel/error-utils": "2.2.0",
42
+ "@vercel/fs-detectors": "6.7.8",
42
43
  "@vercel/frameworks": "3.27.0",
43
- "@vercel/fs-detectors": "6.7.7",
44
44
  "@vercel/routing-utils": "6.2.0"
45
45
  },
46
46
  "scripts": {