@vercel/build-utils 13.14.0 → 13.14.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.
@@ -0,0 +1,15 @@
1
+ import type FileFsRef from './file-fs-ref';
2
+ /**
3
+ * Check if a Node.js/TypeScript file is a valid API entrypoint by detecting
4
+ * export patterns that correspond to supported handler shapes:
5
+ * - Default function export (req, res handler)
6
+ * - Named HTTP method exports (GET, POST, etc.)
7
+ * - Fetch export
8
+ * - module.exports / exports assignments
9
+ *
10
+ * Returns `true` on error as a safe default — if we can't read the file,
11
+ * let the existing build pipeline handle it.
12
+ */
13
+ export declare function isNodeEntrypoint(file: FileFsRef | {
14
+ fsPath?: string;
15
+ }): Promise<boolean>;
@@ -0,0 +1,74 @@
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 node_entrypoint_exports = {};
30
+ __export(node_entrypoint_exports, {
31
+ isNodeEntrypoint: () => isNodeEntrypoint
32
+ });
33
+ module.exports = __toCommonJS(node_entrypoint_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ var import_debug = __toESM(require("./debug"));
36
+ const HTTP_METHODS = "GET|HEAD|OPTIONS|POST|PUT|DELETE|PATCH";
37
+ const VALID_EXPORT_PATTERNS = [
38
+ // ESM default export: export default function handler() {}
39
+ /export\s+default\b/,
40
+ // CJS default export: module.exports = (req, res) => {}
41
+ /module\.exports\s*=/,
42
+ // ESM named HTTP method or fetch exports: export function GET() {}
43
+ new RegExp(
44
+ `export\\s+(?:async\\s+)?(?:function|const|let|var)\\s+(?:${HTTP_METHODS}|fetch)\\b`
45
+ ),
46
+ // ESM re-exports: export { GET } or export { handler as default }
47
+ new RegExp(`export\\s*\\{[^}]*\\b(?:${HTTP_METHODS}|fetch|default)\\b`),
48
+ // CJS named exports: exports.GET = ... or module.exports.GET = ...
49
+ new RegExp(`(?:module\\.)?exports\\.(?:${HTTP_METHODS}|fetch|default)\\s*=`),
50
+ // Server handler: http.createServer(...).listen() with no exports
51
+ /http\.createServer\s*\(/
52
+ ];
53
+ function stripComments(content) {
54
+ return content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
55
+ }
56
+ async function isNodeEntrypoint(file) {
57
+ try {
58
+ const fsPath = file.fsPath;
59
+ if (!fsPath)
60
+ return true;
61
+ const content = await import_fs.default.promises.readFile(fsPath, "utf-8");
62
+ if (!content.trim())
63
+ return false;
64
+ const stripped = stripComments(content);
65
+ return VALID_EXPORT_PATTERNS.some((pattern) => pattern.test(stripped));
66
+ } catch (err) {
67
+ (0, import_debug.default)(`Failed to check Node.js entrypoint: ${err}`);
68
+ return true;
69
+ }
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ isNodeEntrypoint
74
+ });
package/dist/types.d.ts CHANGED
@@ -658,6 +658,12 @@ export interface TriggerEvent extends TriggerEventBase {
658
658
  }
659
659
  export type ServiceRuntime = 'node' | 'python' | 'go' | 'rust' | 'ruby';
660
660
  export type ServiceType = 'web' | 'cron' | 'worker';
661
+ export interface ServiceMount {
662
+ /** URL path prefix where the service is mounted. */
663
+ path?: string;
664
+ /** Optional subdomain this service is mounted on. */
665
+ subdomain?: string;
666
+ }
661
667
  /**
662
668
  * Configuration for a service in vercel.json.
663
669
  * @experimental This feature is experimental and may change.
@@ -684,7 +690,9 @@ export interface ExperimentalServiceConfig {
684
690
  maxDuration?: MaxDuration;
685
691
  includeFiles?: string | string[];
686
692
  excludeFiles?: string | string[];
687
- /** URL prefix for routing */
693
+ /** Preferred routing config alias for routePrefix/subdomain. */
694
+ mount?: string | ServiceMount;
695
+ /** URL prefix for routing (deprecated, use mount instead) */
688
696
  routePrefix?: string;
689
697
  /** Subdomain this service should respond to (web services only). */
690
698
  subdomain?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "13.14.0",
3
+ "version": "13.14.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",