@vercel/build-utils 13.26.6 → 13.27.0

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,12 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 13.27.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 338cc35: Add isPackageInstalled util for detecting dependencies during build.
8
+ Fix Vercel Flags dependency detection for emitting datafiles during builds with OIDC tokens.
9
+
3
10
  ## 13.26.6
4
11
 
5
12
  ### Patch Changes
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
@@ -34600,6 +34600,7 @@ __export(src_exports, {
34600
34600
  isExternalSymlinkTarget: () => isExternalSymlinkTarget,
34601
34601
  isNodeBackendFramework: () => isNodeBackendFramework,
34602
34602
  isNodeEntrypoint: () => isNodeEntrypoint,
34603
+ isPackageInstalled: () => isPackageInstalled,
34603
34604
  isPythonEntrypoint: () => isPythonEntrypoint,
34604
34605
  isPythonFramework: () => isPythonFramework,
34605
34606
  isQueueBackedService: () => isQueueBackedService,
@@ -39012,6 +39013,23 @@ async function getInstalledPackageVersion(packageName, path8) {
39012
39013
  }
39013
39014
  }
39014
39015
 
39016
+ // src/is-package-installed.ts
39017
+ async function isPackageInstalled(packageName, path8) {
39018
+ try {
39019
+ const resolved = require.resolve(packageName, {
39020
+ paths: path8 ? Array.isArray(path8) ? path8 : [path8] : [process.cwd()]
39021
+ });
39022
+ require(resolved);
39023
+ return true;
39024
+ } catch (err) {
39025
+ debug(
39026
+ `Could not resolve package "${packageName}". Package is not installed.`,
39027
+ err
39028
+ );
39029
+ return false;
39030
+ }
39031
+ }
39032
+
39015
39033
  // src/default-cache-path-glob.ts
39016
39034
  var defaultCachePathGlob = "**/{node_modules,.yarn/cache}/**";
39017
39035
 
@@ -40437,6 +40455,7 @@ function getExtendedPayload({
40437
40455
  isExternalSymlinkTarget,
40438
40456
  isNodeBackendFramework,
40439
40457
  isNodeEntrypoint,
40458
+ isPackageInstalled,
40440
40459
  isPythonEntrypoint,
40441
40460
  isPythonFramework,
40442
40461
  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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "13.26.6",
3
+ "version": "13.27.0",
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",