@vercel/build-utils 13.26.6 → 13.27.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 13.27.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 0a170fd: [services] wire `experimentalServicesV2` into `fs-detectors`.
8
+
9
+ ## 13.27.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 338cc35: Add isPackageInstalled util for detecting dependencies during build.
14
+ Fix Vercel Flags dependency detection for emitting datafiles during builds with OIDC tokens.
15
+
3
16
  ## 13.26.6
4
17
 
5
18
  ### Patch Changes
@@ -22,6 +22,7 @@ __export(get_service_url_env_vars_exports, {
22
22
  getServiceUrlEnvVars: () => getServiceUrlEnvVars
23
23
  });
24
24
  module.exports = __toCommonJS(get_service_url_env_vars_exports);
25
+ var import_types = require("./types");
25
26
  function serviceNameToEnvVar(name) {
26
27
  return `${name.replace(/-/g, "_").toUpperCase()}_URL`;
27
28
  }
@@ -56,7 +57,8 @@ function getServiceUrlEnvVars(options) {
56
57
  const baseUrl = origin || deploymentUrl;
57
58
  if (!baseUrl)
58
59
  return {};
59
- const servicesByName = new Map(services.map((s) => [s.name, s]));
60
+ const v1Services = services.filter(import_types.isExperimentalService);
61
+ const servicesByName = new Map(v1Services.map((s) => [s.name, s]));
60
62
  const consumerEnvPrefix = getFrameworkEnvPrefix(
61
63
  consumerService?.framework,
62
64
  frameworkList
@@ -90,15 +92,16 @@ function getExperimentalServiceUrlEnvVars(options) {
90
92
  if (!baseUrl || !services || services.length === 0) {
91
93
  return {};
92
94
  }
95
+ const v1Services = services.filter(import_types.isExperimentalService);
93
96
  const envVars = {};
94
97
  const frameworkPrefixes = /* @__PURE__ */ new Set();
95
- for (const service of services) {
98
+ for (const service of v1Services) {
96
99
  const prefix = getFrameworkEnvPrefix(service.framework, frameworkList);
97
100
  if (prefix) {
98
101
  frameworkPrefixes.add(prefix);
99
102
  }
100
103
  }
101
- for (const service of services) {
104
+ for (const service of v1Services) {
102
105
  if (service.type !== "web" || !service.routePrefix) {
103
106
  continue;
104
107
  }
package/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ export * from './errors';
34
34
  export * from './trace';
35
35
  export { NODE_VERSIONS } from './fs/node-version';
36
36
  export { getInstalledPackageVersion } from './get-installed-package-version';
37
+ export { isPackageInstalled } from './is-package-installed';
37
38
  export { defaultCachePathGlob } from './default-cache-path-glob';
38
39
  export { generateNodeBuilderFunctions } from './generate-node-builder-functions';
39
40
  export { BACKEND_FRAMEWORKS, BACKEND_BUILDERS, UNIFIED_BACKEND_BUILDER, BackendFramework, isBackendFramework, isNodeBackendFramework, isBackendBuilder, isExperimentalBackendsEnabled, isExperimentalBackendsWithoutIntrospectionEnabled, shouldUseExperimentalBackends, PYTHON_FRAMEWORKS, PythonFramework, isPythonFramework, } from './framework-helpers';
package/dist/index.js CHANGED
@@ -34596,10 +34596,13 @@ __export(src_exports, {
34596
34596
  isDirectory: () => isDirectory,
34597
34597
  isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
34598
34598
  isExperimentalBackendsWithoutIntrospectionEnabled: () => isExperimentalBackendsWithoutIntrospectionEnabled,
34599
+ isExperimentalService: () => isExperimentalService,
34600
+ isExperimentalServiceV2: () => isExperimentalServiceV2,
34599
34601
  isExternalSymlink: () => isExternalSymlink,
34600
34602
  isExternalSymlinkTarget: () => isExternalSymlinkTarget,
34601
34603
  isNodeBackendFramework: () => isNodeBackendFramework,
34602
34604
  isNodeEntrypoint: () => isNodeEntrypoint,
34605
+ isPackageInstalled: () => isPackageInstalled,
34603
34606
  isPythonEntrypoint: () => isPythonEntrypoint,
34604
34607
  isPythonFramework: () => isPythonFramework,
34605
34608
  isQueueBackedService: () => isQueueBackedService,
@@ -35851,6 +35854,12 @@ var NodeVersion = class extends Version {
35851
35854
  var BunVersion = class extends Version {
35852
35855
  };
35853
35856
  var JOB_TRIGGERS = ["queue", "schedule", "workflow"];
35857
+ function isExperimentalService(service) {
35858
+ return service.schema === "experimentalServices";
35859
+ }
35860
+ function isExperimentalServiceV2(service) {
35861
+ return service.schema === "experimentalServicesV2";
35862
+ }
35854
35863
  function getServiceQueueTopicConfigs(config) {
35855
35864
  if (Array.isArray(config.topics) && config.topics.length > 0) {
35856
35865
  return typeof config.topics[0] === "string" ? config.topics.map((topic) => ({ topic })) : config.topics;
@@ -38010,7 +38019,8 @@ function getServiceUrlEnvVars(options) {
38010
38019
  const baseUrl = origin || deploymentUrl;
38011
38020
  if (!baseUrl)
38012
38021
  return {};
38013
- const servicesByName = new Map(services.map((s) => [s.name, s]));
38022
+ const v1Services = services.filter(isExperimentalService);
38023
+ const servicesByName = new Map(v1Services.map((s) => [s.name, s]));
38014
38024
  const consumerEnvPrefix = getFrameworkEnvPrefix(
38015
38025
  consumerService?.framework,
38016
38026
  frameworkList
@@ -38044,15 +38054,16 @@ function getExperimentalServiceUrlEnvVars(options) {
38044
38054
  if (!baseUrl || !services || services.length === 0) {
38045
38055
  return {};
38046
38056
  }
38057
+ const v1Services = services.filter(isExperimentalService);
38047
38058
  const envVars = {};
38048
38059
  const frameworkPrefixes = /* @__PURE__ */ new Set();
38049
- for (const service of services) {
38060
+ for (const service of v1Services) {
38050
38061
  const prefix = getFrameworkEnvPrefix(service.framework, frameworkList);
38051
38062
  if (prefix) {
38052
38063
  frameworkPrefixes.add(prefix);
38053
38064
  }
38054
38065
  }
38055
- for (const service of services) {
38066
+ for (const service of v1Services) {
38056
38067
  if (service.type !== "web" || !service.routePrefix) {
38057
38068
  continue;
38058
38069
  }
@@ -39012,6 +39023,23 @@ async function getInstalledPackageVersion(packageName, path8) {
39012
39023
  }
39013
39024
  }
39014
39025
 
39026
+ // src/is-package-installed.ts
39027
+ async function isPackageInstalled(packageName, path8) {
39028
+ try {
39029
+ const resolved = require.resolve(packageName, {
39030
+ paths: path8 ? Array.isArray(path8) ? path8 : [path8] : [process.cwd()]
39031
+ });
39032
+ require(resolved);
39033
+ return true;
39034
+ } catch (err) {
39035
+ debug(
39036
+ `Could not resolve package "${packageName}". Package is not installed.`,
39037
+ err
39038
+ );
39039
+ return false;
39040
+ }
39041
+ }
39042
+
39015
39043
  // src/default-cache-path-glob.ts
39016
39044
  var defaultCachePathGlob = "**/{node_modules,.yarn/cache}/**";
39017
39045
 
@@ -40433,10 +40461,13 @@ function getExtendedPayload({
40433
40461
  isDirectory,
40434
40462
  isExperimentalBackendsEnabled,
40435
40463
  isExperimentalBackendsWithoutIntrospectionEnabled,
40464
+ isExperimentalService,
40465
+ isExperimentalServiceV2,
40436
40466
  isExternalSymlink,
40437
40467
  isExternalSymlinkTarget,
40438
40468
  isNodeBackendFramework,
40439
40469
  isNodeEntrypoint,
40470
+ isPackageInstalled,
40440
40471
  isPythonEntrypoint,
40441
40472
  isPythonFramework,
40442
40473
  isQueueBackedService,
@@ -0,0 +1 @@
1
+ export declare function isPackageInstalled(packageName: string, path?: string | string[]): Promise<boolean>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var is_package_installed_exports = {};
30
+ __export(is_package_installed_exports, {
31
+ isPackageInstalled: () => isPackageInstalled
32
+ });
33
+ module.exports = __toCommonJS(is_package_installed_exports);
34
+ var import_debug = __toESM(require("./debug"));
35
+ async function isPackageInstalled(packageName, path) {
36
+ try {
37
+ const resolved = require.resolve(packageName, {
38
+ paths: path ? Array.isArray(path) ? path : [path] : [process.cwd()]
39
+ });
40
+ require(resolved);
41
+ return true;
42
+ } catch (err) {
43
+ (0, import_debug.default)(
44
+ `Could not resolve package "${packageName}". Package is not installed.`,
45
+ err
46
+ );
47
+ return false;
48
+ }
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ isPackageInstalled
53
+ });
package/dist/types.d.ts CHANGED
@@ -513,7 +513,8 @@ export interface ServiceRefEnvVar {
513
513
  }
514
514
  export type EnvVar = ServiceRefEnvVar;
515
515
  export type EnvVars = Record<string, EnvVar>;
516
- export interface Service {
516
+ export interface ExperimentalService {
517
+ schema: 'experimentalServices';
517
518
  name: string;
518
519
  type: ServiceType;
519
520
  trigger?: JobTrigger;
@@ -534,6 +535,36 @@ export interface Service {
534
535
  topics?: ServiceTopics;
535
536
  env?: EnvVars;
536
537
  }
538
+ export interface ExperimentalServiceV2 {
539
+ schema: 'experimentalServicesV2';
540
+ name: string;
541
+ /** Path to the service root, relative to the project root. */
542
+ root: string;
543
+ framework?: string;
544
+ runtime?: string;
545
+ /** Resolved entrypoint, relative to the service root. */
546
+ entrypoint?: string;
547
+ /** Builder selected by the resolver. */
548
+ builder: Builder;
549
+ installCommand?: string;
550
+ buildCommand?: string;
551
+ devCommand?: string;
552
+ ignoreCommand?: string;
553
+ outputDirectory?: string;
554
+ /** Caller-side bindings to other services. */
555
+ bindings?: ExperimentalServiceV2Binding[];
556
+ /** Function configuration scoped to this service. */
557
+ functions?: BuilderFunctions;
558
+ headers?: Header[];
559
+ redirects?: Redirect[];
560
+ rewrites?: Rewrite[];
561
+ routes?: Route[];
562
+ cleanUrls?: boolean;
563
+ trailingSlash?: boolean;
564
+ }
565
+ export type Service = ExperimentalService | ExperimentalServiceV2;
566
+ export declare function isExperimentalService(service: Service): service is ExperimentalService;
567
+ export declare function isExperimentalServiceV2(service: Service): service is ExperimentalServiceV2;
537
568
  export declare function getServiceQueueTopicConfigs(config: {
538
569
  type?: ServiceType;
539
570
  topics?: ServiceTopics;
package/dist/types.js CHANGED
@@ -25,6 +25,8 @@ __export(types_exports, {
25
25
  getReportedServiceType: () => getReportedServiceType,
26
26
  getServiceQueueTopicConfigs: () => getServiceQueueTopicConfigs,
27
27
  getServiceQueueTopics: () => getServiceQueueTopics,
28
+ isExperimentalService: () => isExperimentalService,
29
+ isExperimentalServiceV2: () => isExperimentalServiceV2,
28
30
  isQueueBackedService: () => isQueueBackedService,
29
31
  isQueueTriggeredService: () => isQueueTriggeredService,
30
32
  isScheduleTriggeredService: () => isScheduleTriggeredService,
@@ -56,6 +58,12 @@ class NodeVersion extends Version {
56
58
  class BunVersion extends Version {
57
59
  }
58
60
  const JOB_TRIGGERS = ["queue", "schedule", "workflow"];
61
+ function isExperimentalService(service) {
62
+ return service.schema === "experimentalServices";
63
+ }
64
+ function isExperimentalServiceV2(service) {
65
+ return service.schema === "experimentalServicesV2";
66
+ }
59
67
  function getServiceQueueTopicConfigs(config) {
60
68
  if (Array.isArray(config.topics) && config.topics.length > 0) {
61
69
  return typeof config.topics[0] === "string" ? config.topics.map((topic) => ({ topic })) : config.topics;
@@ -106,6 +114,8 @@ function getReportedServiceType(service) {
106
114
  getReportedServiceType,
107
115
  getServiceQueueTopicConfigs,
108
116
  getServiceQueueTopics,
117
+ isExperimentalService,
118
+ isExperimentalServiceV2,
109
119
  isQueueBackedService,
110
120
  isQueueTriggeredService,
111
121
  isScheduleTriggeredService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "13.26.6",
3
+ "version": "13.27.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -55,8 +55,8 @@
55
55
  "vitest": "2.0.1",
56
56
  "typescript": "4.9.5",
57
57
  "yazl": "2.5.1",
58
- "@vercel/error-utils": "2.2.0",
59
- "@vercel/routing-utils": "6.2.0"
58
+ "@vercel/routing-utils": "6.2.0",
59
+ "@vercel/error-utils": "2.2.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "node build.mjs",