@vercel/build-utils 12.2.0 → 12.2.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,11 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 12.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Add backend util helpers ([#14152](https://github.com/vercel/vercel/pull/14152))
8
+
3
9
  ## 12.2.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,17 @@
1
+ /**
2
+ * List of backend frameworks supported by the experimental backends feature
3
+ */
4
+ export declare const BACKEND_FRAMEWORKS: readonly ["express", "hono", "h3", "nestjs", "fastify"];
5
+ export type BackendFramework = (typeof BACKEND_FRAMEWORKS)[number];
6
+ /**
7
+ * Checks if the given framework is a backend framework
8
+ */
9
+ export declare function isBackendFramework(framework: string | null | undefined): framework is BackendFramework;
10
+ /**
11
+ * Checks if experimental backends are enabled via environment variable
12
+ */
13
+ export declare function isExperimentalBackendsEnabled(): boolean;
14
+ /**
15
+ * Checks if experimental backends are enabled AND the framework is a backend framework
16
+ */
17
+ export declare function shouldUseExperimentalBackends(framework: string | null | undefined): boolean;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var framework_helpers_exports = {};
20
+ __export(framework_helpers_exports, {
21
+ BACKEND_FRAMEWORKS: () => BACKEND_FRAMEWORKS,
22
+ isBackendFramework: () => isBackendFramework,
23
+ isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
24
+ shouldUseExperimentalBackends: () => shouldUseExperimentalBackends
25
+ });
26
+ module.exports = __toCommonJS(framework_helpers_exports);
27
+ const BACKEND_FRAMEWORKS = [
28
+ "express",
29
+ "hono",
30
+ "h3",
31
+ "nestjs",
32
+ "fastify"
33
+ ];
34
+ function isBackendFramework(framework) {
35
+ if (!framework)
36
+ return false;
37
+ return BACKEND_FRAMEWORKS.includes(framework);
38
+ }
39
+ function isExperimentalBackendsEnabled() {
40
+ return process.env.VERCEL_EXPERIMENTAL_BACKENDS === "1" || // Previously used for experimental express and hono builds
41
+ process.env.VERCEL_EXPERIMENTAL_EXPRESS_BUILD === "1" || process.env.VERCEL_EXPERIMENTAL_HONO_BUILD === "1";
42
+ }
43
+ function shouldUseExperimentalBackends(framework) {
44
+ return isExperimentalBackendsEnabled() && isBackendFramework(framework);
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ BACKEND_FRAMEWORKS,
49
+ isBackendFramework,
50
+ isExperimentalBackendsEnabled,
51
+ shouldUseExperimentalBackends
52
+ });
package/dist/index.d.ts CHANGED
@@ -32,3 +32,4 @@ export { NODE_VERSIONS } from './fs/node-version';
32
32
  export { getInstalledPackageVersion } from './get-installed-package-version';
33
33
  export { defaultCachePathGlob } from './default-cache-path-glob';
34
34
  export { generateNodeBuilderFunctions } from './generate-node-builder-functions';
35
+ export { BACKEND_FRAMEWORKS, BackendFramework, isBackendFramework, isExperimentalBackendsEnabled, shouldUseExperimentalBackends, } from './framework-helpers';
package/dist/index.js CHANGED
@@ -21817,6 +21817,7 @@ var require_ignore = __commonJS({
21817
21817
  // src/index.ts
21818
21818
  var src_exports = {};
21819
21819
  __export(src_exports, {
21820
+ BACKEND_FRAMEWORKS: () => BACKEND_FRAMEWORKS,
21820
21821
  BUILDER_COMPILE_STEP: () => BUILDER_COMPILE_STEP,
21821
21822
  BUILDER_INSTALLER_STEP: () => BUILDER_INSTALLER_STEP,
21822
21823
  BunVersion: () => BunVersion,
@@ -21866,8 +21867,10 @@ __export(src_exports, {
21866
21867
  glob: () => glob,
21867
21868
  hardLinkDir: () => hardLinkDir,
21868
21869
  installDependencies: () => installDependencies,
21870
+ isBackendFramework: () => isBackendFramework,
21869
21871
  isBunVersion: () => isBunVersion,
21870
21872
  isDirectory: () => isDirectory,
21873
+ isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
21871
21874
  isSymbolicLink: () => isSymbolicLink,
21872
21875
  normalizePath: () => normalizePath,
21873
21876
  readConfigFile: () => readConfigFile,
@@ -21880,6 +21883,7 @@ __export(src_exports, {
21880
21883
  runShellScript: () => runShellScript,
21881
21884
  scanParentDirs: () => scanParentDirs,
21882
21885
  shouldServe: () => shouldServe,
21886
+ shouldUseExperimentalBackends: () => shouldUseExperimentalBackends,
21883
21887
  spawnAsync: () => spawnAsync,
21884
21888
  spawnCommand: () => spawnCommand,
21885
21889
  streamToBuffer: () => streamToBuffer,
@@ -24761,8 +24765,30 @@ ${entrypointsForMessage}`
24761
24765
  entrypointCallback
24762
24766
  };
24763
24767
  }
24768
+
24769
+ // src/framework-helpers.ts
24770
+ var BACKEND_FRAMEWORKS = [
24771
+ "express",
24772
+ "hono",
24773
+ "h3",
24774
+ "nestjs",
24775
+ "fastify"
24776
+ ];
24777
+ function isBackendFramework(framework) {
24778
+ if (!framework)
24779
+ return false;
24780
+ return BACKEND_FRAMEWORKS.includes(framework);
24781
+ }
24782
+ function isExperimentalBackendsEnabled() {
24783
+ return process.env.VERCEL_EXPERIMENTAL_BACKENDS === "1" || // Previously used for experimental express and hono builds
24784
+ process.env.VERCEL_EXPERIMENTAL_EXPRESS_BUILD === "1" || process.env.VERCEL_EXPERIMENTAL_HONO_BUILD === "1";
24785
+ }
24786
+ function shouldUseExperimentalBackends(framework) {
24787
+ return isExperimentalBackendsEnabled() && isBackendFramework(framework);
24788
+ }
24764
24789
  // Annotate the CommonJS export names for ESM import in node:
24765
24790
  0 && (module.exports = {
24791
+ BACKEND_FRAMEWORKS,
24766
24792
  BUILDER_COMPILE_STEP,
24767
24793
  BUILDER_INSTALLER_STEP,
24768
24794
  BunVersion,
@@ -24812,8 +24838,10 @@ ${entrypointsForMessage}`
24812
24838
  glob,
24813
24839
  hardLinkDir,
24814
24840
  installDependencies,
24841
+ isBackendFramework,
24815
24842
  isBunVersion,
24816
24843
  isDirectory,
24844
+ isExperimentalBackendsEnabled,
24817
24845
  isSymbolicLink,
24818
24846
  normalizePath,
24819
24847
  readConfigFile,
@@ -24826,6 +24854,7 @@ ${entrypointsForMessage}`
24826
24854
  runShellScript,
24827
24855
  scanParentDirs,
24828
24856
  shouldServe,
24857
+ shouldUseExperimentalBackends,
24829
24858
  spawnAsync,
24830
24859
  spawnCommand,
24831
24860
  streamToBuffer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "12.2.0",
3
+ "version": "12.2.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -27,7 +27,7 @@
27
27
  "@types/semver": "6.0.0",
28
28
  "@types/yazl": "2.4.2",
29
29
  "@vercel/error-utils": "2.0.3",
30
- "@vercel/routing-utils": "5.2.0",
30
+ "@vercel/routing-utils": "5.2.1",
31
31
  "aggregate-error": "3.0.1",
32
32
  "async-retry": "1.2.3",
33
33
  "async-sema": "2.1.4",