@vercel/backends
Advanced tools
| //#region src/introspection/express.d.ts | ||
| declare const handle: (expressModule: any) => any; | ||
| //#endregion | ||
| export { handle }; |
| import { pathToRegexp } from "path-to-regexp"; | ||
| import { debug } from "@vercel/build-utils"; | ||
| //#region src/introspection/util.ts | ||
| const BEGIN_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_BEGIN__\n"; | ||
| const END_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_END__\n"; | ||
| const setupCloseHandlers = (cb) => { | ||
| const callCallback = () => { | ||
| const result = cb(); | ||
| if (result) console.log(`${BEGIN_INTROSPECTION_RESULT}${JSON.stringify(result)}${END_INTROSPECTION_RESULT}`); | ||
| }; | ||
| process.on("SIGINT", callCallback); | ||
| process.on("SIGTERM", callCallback); | ||
| process.on("exit", callCallback); | ||
| }; | ||
| //#endregion | ||
| //#region src/introspection/express.ts | ||
| let app = null; | ||
| const handle = (expressModule) => { | ||
| if (typeof expressModule === "function") { | ||
| const originalCreateApp = expressModule; | ||
| const createApp = (...args) => { | ||
| app = originalCreateApp(...args); | ||
| return app; | ||
| }; | ||
| Object.setPrototypeOf(createApp, originalCreateApp); | ||
| Object.assign(createApp, originalCreateApp); | ||
| return createApp; | ||
| } | ||
| return expressModule; | ||
| }; | ||
| setupCloseHandlers(() => { | ||
| const { routes, additionalFolders, additionalDeps } = extractRoutes(); | ||
| if (routes.length > 0) return { | ||
| frameworkSlug: "express", | ||
| routes, | ||
| additionalFolders, | ||
| additionalDeps | ||
| }; | ||
| }); | ||
| const extractRoutes = () => { | ||
| if (!app) return { | ||
| routes: [], | ||
| additionalFolders: [], | ||
| additionalDeps: [] | ||
| }; | ||
| const additionalFolders = []; | ||
| const additionalDeps = []; | ||
| const routes = []; | ||
| const methods = [ | ||
| "all", | ||
| "get", | ||
| "post", | ||
| "put", | ||
| "delete", | ||
| "patch", | ||
| "options", | ||
| "head" | ||
| ]; | ||
| const router = app._router || app.router; | ||
| if ("settings" in app) { | ||
| if ("views" in app.settings && typeof app.settings.views === "string") additionalFolders.push(app.settings.views); | ||
| if ("view engine" in app.settings && typeof app.settings["view engine"] === "string") additionalDeps.push(app.settings["view engine"]); | ||
| } | ||
| for (const route of router.stack) if (route.route) { | ||
| const m = []; | ||
| for (const method of methods) if (route.route.methods[method]) m.push(method.toUpperCase()); | ||
| try { | ||
| const { regexp } = pathToRegexp(route.route.path); | ||
| if (route.route.path === "/") continue; | ||
| routes.push({ | ||
| src: regexp.source, | ||
| dest: route.route.path, | ||
| methods: m | ||
| }); | ||
| } catch (e) { | ||
| const message = e instanceof Error ? e.message : "Unknown error"; | ||
| debug(`Error extracting routes for ${route.route.path}: ${message}`); | ||
| } | ||
| } | ||
| return { | ||
| routes, | ||
| additionalFolders, | ||
| additionalDeps | ||
| }; | ||
| }; | ||
| //#endregion | ||
| export { handle }; |
| //#region src/introspection/hono.d.ts | ||
| declare const handle: (honoModule: any) => { | ||
| new (...args: any[]): { | ||
| [x: string]: any; | ||
| }; | ||
| [x: string]: any; | ||
| }; | ||
| //#endregion | ||
| export { handle }; |
| import { pathToRegexp } from "path-to-regexp"; | ||
| import { debug } from "@vercel/build-utils"; | ||
| //#region src/introspection/util.ts | ||
| const BEGIN_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_BEGIN__\n"; | ||
| const END_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_END__\n"; | ||
| const setupCloseHandlers = (cb) => { | ||
| const callCallback = () => { | ||
| const result = cb(); | ||
| if (result) console.log(`${BEGIN_INTROSPECTION_RESULT}${JSON.stringify(result)}${END_INTROSPECTION_RESULT}`); | ||
| }; | ||
| process.on("SIGINT", callCallback); | ||
| process.on("SIGTERM", callCallback); | ||
| process.on("exit", callCallback); | ||
| }; | ||
| //#endregion | ||
| //#region src/introspection/hono.ts | ||
| const apps = []; | ||
| const handle = (honoModule) => { | ||
| const TrackedHono = class extends honoModule.Hono { | ||
| constructor(...args) { | ||
| super(...args); | ||
| apps.push(this); | ||
| } | ||
| }; | ||
| return TrackedHono; | ||
| }; | ||
| setupCloseHandlers(() => { | ||
| const routes = extractRoutes(); | ||
| if (routes.length > 0) return { | ||
| frameworkSlug: "hono", | ||
| routes | ||
| }; | ||
| }); | ||
| function extractRoutes() { | ||
| const app = apps.sort((a, b) => b.routes.length - a.routes.length)[0]; | ||
| if (!app || !app.routes) return []; | ||
| const routes = []; | ||
| for (const route of app.routes) { | ||
| const routePath = route.path; | ||
| const method = route.method.toUpperCase(); | ||
| try { | ||
| const { regexp } = pathToRegexp(routePath); | ||
| if (routePath === "/") continue; | ||
| routes.push({ | ||
| src: regexp.source, | ||
| dest: routePath, | ||
| methods: [method] | ||
| }); | ||
| } catch (e) { | ||
| debug(`Error extracting routes for ${routePath}: ${e instanceof Error ? e.message : "Unknown error"}`); | ||
| } | ||
| } | ||
| return routes; | ||
| } | ||
| //#endregion | ||
| export { handle }; |
| //#region rolldown:runtime | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| //#endregion | ||
| let module$1 = require("module"); | ||
| module$1 = __toESM(module$1); | ||
| let path_to_regexp = require("path-to-regexp"); | ||
| let __vercel_build_utils = require("@vercel/build-utils"); | ||
| //#region src/introspection/util.ts | ||
| const BEGIN_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_BEGIN__\n"; | ||
| const END_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_END__\n"; | ||
| const setupCloseHandlers = (cb) => { | ||
| const callCallback = () => { | ||
| const result = cb(); | ||
| if (result) console.log(`${BEGIN_INTROSPECTION_RESULT}${JSON.stringify(result)}${END_INTROSPECTION_RESULT}`); | ||
| }; | ||
| process.on("SIGINT", callCallback); | ||
| process.on("SIGTERM", callCallback); | ||
| process.on("exit", callCallback); | ||
| }; | ||
| //#endregion | ||
| //#region src/introspection/hono.ts | ||
| const apps = []; | ||
| const handle = (honoModule) => { | ||
| const TrackedHono = class extends honoModule.Hono { | ||
| constructor(...args) { | ||
| super(...args); | ||
| apps.push(this); | ||
| } | ||
| }; | ||
| return TrackedHono; | ||
| }; | ||
| setupCloseHandlers(() => { | ||
| const routes = extractRoutes$1(); | ||
| if (routes.length > 0) return { | ||
| frameworkSlug: "hono", | ||
| routes | ||
| }; | ||
| }); | ||
| function extractRoutes$1() { | ||
| const app$1 = apps.sort((a, b) => b.routes.length - a.routes.length)[0]; | ||
| if (!app$1 || !app$1.routes) return []; | ||
| const routes = []; | ||
| for (const route of app$1.routes) { | ||
| const routePath = route.path; | ||
| const method = route.method.toUpperCase(); | ||
| try { | ||
| const { regexp } = (0, path_to_regexp.pathToRegexp)(routePath); | ||
| if (routePath === "/") continue; | ||
| routes.push({ | ||
| src: regexp.source, | ||
| dest: routePath, | ||
| methods: [method] | ||
| }); | ||
| } catch (e) { | ||
| (0, __vercel_build_utils.debug)(`Error extracting routes for ${routePath}: ${e instanceof Error ? e.message : "Unknown error"}`); | ||
| } | ||
| } | ||
| return routes; | ||
| } | ||
| //#endregion | ||
| //#region src/introspection/express.ts | ||
| let app = null; | ||
| const handle$1 = (expressModule) => { | ||
| if (typeof expressModule === "function") { | ||
| const originalCreateApp = expressModule; | ||
| const createApp = (...args) => { | ||
| app = originalCreateApp(...args); | ||
| return app; | ||
| }; | ||
| Object.setPrototypeOf(createApp, originalCreateApp); | ||
| Object.assign(createApp, originalCreateApp); | ||
| return createApp; | ||
| } | ||
| return expressModule; | ||
| }; | ||
| setupCloseHandlers(() => { | ||
| const { routes, additionalFolders, additionalDeps } = extractRoutes(); | ||
| if (routes.length > 0) return { | ||
| frameworkSlug: "express", | ||
| routes, | ||
| additionalFolders, | ||
| additionalDeps | ||
| }; | ||
| }); | ||
| const extractRoutes = () => { | ||
| if (!app) return { | ||
| routes: [], | ||
| additionalFolders: [], | ||
| additionalDeps: [] | ||
| }; | ||
| const additionalFolders = []; | ||
| const additionalDeps = []; | ||
| const routes = []; | ||
| const methods = [ | ||
| "all", | ||
| "get", | ||
| "post", | ||
| "put", | ||
| "delete", | ||
| "patch", | ||
| "options", | ||
| "head" | ||
| ]; | ||
| const router = app._router || app.router; | ||
| if ("settings" in app) { | ||
| if ("views" in app.settings && typeof app.settings.views === "string") additionalFolders.push(app.settings.views); | ||
| if ("view engine" in app.settings && typeof app.settings["view engine"] === "string") additionalDeps.push(app.settings["view engine"]); | ||
| } | ||
| for (const route of router.stack) if (route.route) { | ||
| const m = []; | ||
| for (const method of methods) if (route.route.methods[method]) m.push(method.toUpperCase()); | ||
| try { | ||
| const { regexp } = (0, path_to_regexp.pathToRegexp)(route.route.path); | ||
| if (route.route.path === "/") continue; | ||
| routes.push({ | ||
| src: regexp.source, | ||
| dest: route.route.path, | ||
| methods: m | ||
| }); | ||
| } catch (e) { | ||
| const message = e instanceof Error ? e.message : "Unknown error"; | ||
| (0, __vercel_build_utils.debug)(`Error extracting routes for ${route.route.path}: ${message}`); | ||
| } | ||
| } | ||
| return { | ||
| routes, | ||
| additionalFolders, | ||
| additionalDeps | ||
| }; | ||
| }; | ||
| //#endregion | ||
| //#region src/introspection/loaders/cjs.ts | ||
| const originalRequire = module$1.default.prototype.require; | ||
| module$1.default.prototype.require = function(id, ...args) { | ||
| const result = originalRequire.apply(this, [id, ...args]); | ||
| if (id === "express") return handle$1(result); | ||
| if (id === "hono") return { | ||
| ...result, | ||
| Hono: handle(result) | ||
| }; | ||
| return result; | ||
| }; | ||
| //#endregion |
| export { }; |
| export { }; |
| import { register } from "node:module"; | ||
| //#region src/introspection/loaders/esm.ts | ||
| register(new URL("./hooks.mjs", import.meta.url), import.meta.url); | ||
| //#endregion | ||
| export { }; |
| //#region src/introspection/loaders/hooks.d.ts | ||
| declare function resolve(specifier: string, context: any, nextResolve: any): Promise<any>; | ||
| declare function load(url: string, context: any, nextLoad: (url: string, context: any) => Promise<any>): Promise<any>; | ||
| //#endregion | ||
| export { load, resolve }; |
| //#region src/introspection/loaders/hooks.ts | ||
| let honoUrl = null; | ||
| let expressUrl = null; | ||
| async function resolve(specifier, context, nextResolve) { | ||
| const result = await nextResolve(specifier, context); | ||
| if (specifier === "hono") honoUrl = result.url; | ||
| else if (specifier === "express") expressUrl = result.url; | ||
| return result; | ||
| } | ||
| async function load(url, context, nextLoad) { | ||
| const result = await nextLoad(url, context); | ||
| if (expressUrl === url) { | ||
| const pathToExpressExtract = new URL("../express.mjs", import.meta.url); | ||
| return { | ||
| format: "module", | ||
| source: ` | ||
| import { handle} from ${JSON.stringify(pathToExpressExtract.toString())}; | ||
| import originalExpress from ${JSON.stringify(url + "?original")}; | ||
| const extendedExpress = handle(originalExpress); | ||
| export * from ${JSON.stringify(url + "?original")}; | ||
| export default extendedExpress; | ||
| `, | ||
| shortCircuit: true | ||
| }; | ||
| } | ||
| if (honoUrl === url) { | ||
| const pathToHonoExtract = new URL("../hono.mjs", import.meta.url); | ||
| return { | ||
| format: "module", | ||
| source: ` | ||
| import { handle } from ${JSON.stringify(pathToHonoExtract.toString())}; | ||
| import * as originalHono from ${JSON.stringify(url + "?original")}; | ||
| export * from ${JSON.stringify(url + "?original")}; | ||
| export const Hono = handle(originalHono); | ||
| `, | ||
| shortCircuit: true | ||
| }; | ||
| } | ||
| if (url.endsWith("?original")) { | ||
| const originalUrl = url.replace("?original", ""); | ||
| if (originalUrl === honoUrl || originalUrl === expressUrl) return result; | ||
| } | ||
| return result; | ||
| } | ||
| //#endregion | ||
| export { load, resolve }; |
| export { }; |
| import { register } from "node:module"; | ||
| //#region src/introspection/loaders/rolldown-esm.ts | ||
| register(new URL("./rolldown-hooks.mjs", import.meta.url), import.meta.url); | ||
| //#endregion | ||
| export { }; |
| /// <reference types="node" resolution-mode="require"/> | ||
| //#region src/introspection/loaders/rolldown-hooks.d.ts | ||
| declare function resolve(specifier: string, context: { | ||
| parentURL?: string; | ||
| }, nextResolve: (specifier: string, context: { | ||
| parentURL?: string; | ||
| }) => Promise<{ | ||
| url: string; | ||
| }>): Promise<{ | ||
| url: string; | ||
| } | { | ||
| url: string; | ||
| shortCircuit: boolean; | ||
| }>; | ||
| declare function load(url: string, context: { | ||
| format?: string; | ||
| }, nextLoad: (url: string, context: { | ||
| format?: string; | ||
| }) => Promise<{ | ||
| format: string; | ||
| source: string | Buffer; | ||
| }>): Promise<{ | ||
| format: string; | ||
| source: string | Buffer; | ||
| } | { | ||
| format: string; | ||
| source: string; | ||
| shortCircuit: boolean; | ||
| }>; | ||
| //#endregion | ||
| export { load, resolve }; |
| import { builtinModules } from "node:module"; | ||
| import { build } from "rolldown"; | ||
| import { fileURLToPath, pathToFileURL } from "node:url"; | ||
| import { dirname, extname, join, relative } from "node:path"; | ||
| import { existsSync } from "node:fs"; | ||
| import { readFile } from "node:fs/promises"; | ||
| import { exports } from "resolve.exports"; | ||
| import "@vercel/build-utils"; | ||
| import "@vercel/nft"; | ||
| import "oxc-transform"; | ||
| //#region src/cervel/plugin.ts | ||
| const CJS_SHIM_PREFIX = "\0cjs-shim:"; | ||
| const plugin = (args) => { | ||
| const packageJsonCache = /* @__PURE__ */ new Map(); | ||
| const shimMeta = /* @__PURE__ */ new Map(); | ||
| const { tracedPaths } = args.context; | ||
| const isBareImport = (id) => { | ||
| return !id.startsWith(".") && !id.startsWith("/") && !/^[a-z][a-z0-9+.-]*:/i.test(id); | ||
| }; | ||
| /** | ||
| * Read and cache package.json contents | ||
| */ | ||
| const getPackageJson = async (pkgPath) => { | ||
| if (packageJsonCache.has(pkgPath)) return packageJsonCache.get(pkgPath); | ||
| try { | ||
| const contents = await readFile(pkgPath, "utf-8"); | ||
| const parsed = JSON.parse(contents); | ||
| packageJsonCache.set(pkgPath, parsed); | ||
| return parsed; | ||
| } catch { | ||
| packageJsonCache.set(pkgPath, null); | ||
| return null; | ||
| } | ||
| }; | ||
| /** | ||
| * Determine if a resolved module is CommonJS based on package.json exports | ||
| */ | ||
| const isCommonJS = async (bareImport, resolvedPath, resolvedInfo) => { | ||
| const ext = extname(resolvedPath); | ||
| if (ext === ".cjs") return true; | ||
| if (ext === ".mjs") return false; | ||
| if (ext === ".js" || ext === ".ts") { | ||
| const pkgJsonPath = resolvedInfo.packageJsonPath; | ||
| if (!pkgJsonPath) return true; | ||
| const pkgJson = await getPackageJson(pkgJsonPath); | ||
| if (!pkgJson) return true; | ||
| const pkgDir = dirname(pkgJsonPath); | ||
| const relativePath = resolvedPath.startsWith(pkgDir) ? resolvedPath.slice(pkgDir.length + 1).replace(/\\/g, "/") : null; | ||
| if (!relativePath) return pkgJson.type !== "module"; | ||
| const pkgName = pkgJson.name || ""; | ||
| const subpath = bareImport.startsWith(pkgName) ? `.${bareImport.slice(pkgName.length)}` || "." : "."; | ||
| try { | ||
| if (exports(pkgJson, subpath, { | ||
| require: false, | ||
| conditions: ["node", "import"] | ||
| })?.some((p) => p === relativePath || p === `./${relativePath}`)) return false; | ||
| if (exports(pkgJson, subpath, { | ||
| require: true, | ||
| conditions: ["node", "require"] | ||
| })?.some((p) => p === relativePath || p === `./${relativePath}`)) return true; | ||
| } catch (err) { | ||
| console.warn("Export resolution failed::", err); | ||
| } | ||
| if (pkgJson.module) return false; | ||
| return pkgJson.type !== "module"; | ||
| } | ||
| return true; | ||
| }; | ||
| const isLocalImport = (id) => { | ||
| if (id.startsWith("node:")) return false; | ||
| if (id.includes("node_modules")) return false; | ||
| return true; | ||
| }; | ||
| return { | ||
| name: "cervel", | ||
| resolveId: { | ||
| order: "pre", | ||
| async handler(id, importer, rOpts) { | ||
| if (id.startsWith(CJS_SHIM_PREFIX)) return { | ||
| id, | ||
| external: false | ||
| }; | ||
| const resolved = await this.resolve(id, importer, rOpts); | ||
| if (builtinModules.includes(id)) return { | ||
| id: `node:${id}`, | ||
| external: true | ||
| }; | ||
| if (resolved?.id && isLocalImport(resolved.id)) tracedPaths.add(resolved.id); | ||
| if (importer?.startsWith(CJS_SHIM_PREFIX) && isBareImport(id)) return { | ||
| id, | ||
| external: true | ||
| }; | ||
| if (importer && isBareImport(id) && resolved?.id?.includes("node_modules")) { | ||
| if (args.shimBareImports) { | ||
| if (await isCommonJS(id, resolved.id, resolved)) { | ||
| const importerPkgJsonPath = (await this.resolve(importer))?.packageJsonPath; | ||
| if (importerPkgJsonPath) { | ||
| const importerPkgDir = relative(args.repoRootPath, dirname(importerPkgJsonPath)); | ||
| const shimId$1 = `${CJS_SHIM_PREFIX}${importerPkgDir.replace(/\//g, "_")}_${id.replace(/\//g, "_")}`; | ||
| shimMeta.set(shimId$1, { | ||
| pkgDir: importerPkgDir, | ||
| pkgName: id | ||
| }); | ||
| return { | ||
| id: shimId$1, | ||
| external: false | ||
| }; | ||
| } | ||
| const shimId = `${CJS_SHIM_PREFIX}${id.replace(/\//g, "_")}`; | ||
| shimMeta.set(shimId, { | ||
| pkgDir: "", | ||
| pkgName: id | ||
| }); | ||
| return { | ||
| id: shimId, | ||
| external: false | ||
| }; | ||
| } | ||
| } | ||
| return { | ||
| external: true, | ||
| id | ||
| }; | ||
| } | ||
| if (importer && isBareImport(id)) return resolved; | ||
| return { | ||
| external: true, | ||
| ...resolved, | ||
| id: resolved?.id || id | ||
| }; | ||
| } | ||
| }, | ||
| load: { async handler(id) { | ||
| if (id.startsWith(CJS_SHIM_PREFIX)) { | ||
| const meta = shimMeta.get(id); | ||
| if (!meta) return { code: `module.exports = require('${id.slice(10)}');` }; | ||
| const { pkgDir, pkgName } = meta; | ||
| if (pkgDir) return { code: ` | ||
| import { createRequire } from 'node:module'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { dirname, join } from 'node:path'; | ||
| const requireFromContext = createRequire(join(dirname(fileURLToPath(import.meta.url)), '${join("..", pkgDir, "package.json")}')); | ||
| module.exports = requireFromContext('${pkgName}'); | ||
| `.trim() }; | ||
| return { code: `module.exports = require('${pkgName}');` }; | ||
| } | ||
| return null; | ||
| } } | ||
| }; | ||
| }; | ||
| //#endregion | ||
| //#region src/cervel/rolldown.ts | ||
| const __dirname__filenameShim = ` | ||
| import { createRequire as __createRequire } from 'node:module'; | ||
| import { fileURLToPath as __fileURLToPath } from 'node:url'; | ||
| import { dirname as __dirname_ } from 'node:path'; | ||
| var require = typeof require !== 'undefined' ? require : __createRequire(import.meta.url); | ||
| var __filename = typeof __filename !== 'undefined' ? __filename : __fileURLToPath(import.meta.url); | ||
| var __dirname = typeof __dirname !== 'undefined' ? __dirname : __dirname_(__filename); | ||
| `.trim(); | ||
| //#endregion | ||
| //#region src/introspection/loaders/rolldown-hooks.ts | ||
| function findProjectRoot(startDir) { | ||
| let dir = startDir; | ||
| while (dir !== "/" && dir !== ".") { | ||
| if (existsSync(join(dir, "package.json"))) return dir; | ||
| dir = dirname(dir); | ||
| } | ||
| return startDir; | ||
| } | ||
| let honoUrl = null; | ||
| let expressUrl = null; | ||
| const chunkCache = /* @__PURE__ */ new Map(); | ||
| const bundled = /* @__PURE__ */ new Set(); | ||
| async function resolve(specifier, context, nextResolve) { | ||
| if (context.parentURL && specifier.startsWith("./")) { | ||
| const resolvedUrl = pathToFileURL(join(dirname(fileURLToPath(context.parentURL)), specifier)).href; | ||
| if (chunkCache.has(resolvedUrl)) return { | ||
| url: resolvedUrl, | ||
| shortCircuit: true | ||
| }; | ||
| } | ||
| const result = await nextResolve(specifier, context); | ||
| if (specifier === "hono") honoUrl = result.url; | ||
| else if (specifier === "express") expressUrl = result.url; | ||
| return result; | ||
| } | ||
| async function load(url, context, nextLoad) { | ||
| if (honoUrl === url) { | ||
| const pathToHonoExtract = new URL("../hono.mjs", import.meta.url); | ||
| return { | ||
| format: "module", | ||
| source: ` | ||
| import { handle } from ${JSON.stringify(pathToHonoExtract.toString())}; | ||
| import * as originalHono from ${JSON.stringify(url + "?original")}; | ||
| export * from ${JSON.stringify(url + "?original")}; | ||
| export const Hono = handle(originalHono); | ||
| `, | ||
| shortCircuit: true | ||
| }; | ||
| } | ||
| if (expressUrl === url) { | ||
| const pathToExpressExtract = new URL("../express.mjs", import.meta.url); | ||
| return { | ||
| format: "module", | ||
| source: ` | ||
| import { handle } from ${JSON.stringify(pathToExpressExtract.toString())}; | ||
| import originalExpress from ${JSON.stringify(url + "?original")}; | ||
| const extendedExpress = handle(originalExpress); | ||
| export * from ${JSON.stringify(url + "?original")}; | ||
| export default extendedExpress; | ||
| `, | ||
| shortCircuit: true | ||
| }; | ||
| } | ||
| if (url.endsWith("?original")) return nextLoad(url, context); | ||
| const cached = chunkCache.get(url); | ||
| if (cached) return { | ||
| format: "module", | ||
| source: cached, | ||
| shortCircuit: true | ||
| }; | ||
| if (url.startsWith("file://") && !bundled.has(url) && !url.includes("/node_modules/")) { | ||
| bundled.add(url); | ||
| const filePath = fileURLToPath(url); | ||
| const fileDir = dirname(filePath); | ||
| const projectRoot = findProjectRoot(fileDir); | ||
| const result = await build({ | ||
| input: filePath, | ||
| write: false, | ||
| platform: "node", | ||
| cwd: projectRoot, | ||
| plugins: [plugin({ | ||
| repoRootPath: projectRoot, | ||
| outDir: fileDir, | ||
| workPath: projectRoot, | ||
| shimBareImports: true, | ||
| context: { tracedPaths: /* @__PURE__ */ new Set() } | ||
| })], | ||
| output: { | ||
| format: "esm", | ||
| banner: __dirname__filenameShim | ||
| } | ||
| }); | ||
| for (const chunk of result.output) if (chunk.type === "chunk") { | ||
| const chunkUrl = pathToFileURL(join(fileDir, chunk.fileName)).href; | ||
| chunkCache.set(chunkUrl, chunk.code); | ||
| } | ||
| const entryChunk = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry); | ||
| if (entryChunk && entryChunk.type === "chunk") return { | ||
| format: "module", | ||
| source: entryChunk.code, | ||
| shortCircuit: true | ||
| }; | ||
| return { | ||
| format: "module", | ||
| source: result.output[0].code, | ||
| shortCircuit: true | ||
| }; | ||
| } | ||
| return nextLoad(url, context); | ||
| } | ||
| //#endregion | ||
| export { load, resolve }; |
+100
-2
@@ -1,3 +0,101 @@ | ||
| import { BuildV2, PrepareCache } from "@vercel/build-utils"; | ||
| /// <reference types="node" resolution-mode="require"/> | ||
| import * as _vercel_build_utils0 from "@vercel/build-utils"; | ||
| import { BuildOptions, BuildV2, Files, PrepareCache, Span } from "@vercel/build-utils"; | ||
| import { ParseArgsConfig } from "node:util"; | ||
| //#region src/cervel/find-entrypoint.d.ts | ||
| declare const findEntrypoint: (cwd: string, options?: { | ||
| ignoreRegex?: boolean; | ||
| }) => Promise<string>; | ||
| //#endregion | ||
| //#region src/cervel/types.d.ts | ||
| /** | ||
| * Core path options derived from BuildOptions. | ||
| * - workPath: the workspace/project directory (where package.json is) | ||
| * - repoRootPath: the root of the monorepo/repo | ||
| */ | ||
| type PathOptions = Pick<BuildOptions, 'workPath' | 'repoRootPath'>; | ||
| /** | ||
| * Options for the cervel build function. | ||
| */ | ||
| type CervelBuildOptions = PathOptions & { | ||
| entrypoint?: string; | ||
| out: string; | ||
| span?: Span; | ||
| }; | ||
| /** | ||
| * Options for the cervel serve function. | ||
| */ | ||
| type CervelServeOptions = Pick<BuildOptions, 'workPath'> & { | ||
| rest: Record<string, string | boolean | undefined>; | ||
| }; | ||
| /** | ||
| * Options for node file tracing. | ||
| */ | ||
| type NodeFileTraceOptions = PathOptions & { | ||
| keepTracedPaths: boolean; | ||
| outDir: string; | ||
| tracedPaths: string[]; | ||
| span: Span; | ||
| }; | ||
| //#endregion | ||
| //#region src/cervel/node-file-trace.d.ts | ||
| declare const nodeFileTrace: (args: NodeFileTraceOptions) => Promise<Files>; | ||
| //#endregion | ||
| //#region src/cervel/index.d.ts | ||
| type ParseArgsOptionsConfig = NonNullable<ParseArgsConfig['options']>; | ||
| declare const getBuildSummary: (outputDir: string) => Promise<any>; | ||
| declare const build$1: (args: CervelBuildOptions) => Promise<{ | ||
| rolldownResult: { | ||
| handler: string; | ||
| outputDir: string; | ||
| outputFiles: _vercel_build_utils0.Files; | ||
| }; | ||
| }>; | ||
| declare const serve: (args: CervelServeOptions) => Promise<void>; | ||
| declare const srvxOptions: ParseArgsOptionsConfig; | ||
| //#endregion | ||
| //#region src/introspection/index.d.ts | ||
| declare const introspectApp: (args: { | ||
| dir: string; | ||
| handler: string; | ||
| framework: string | null | undefined; | ||
| env: Record<string, string | undefined>; | ||
| span: Span; | ||
| }) => Promise<{ | ||
| routes: ({ | ||
| handle: string; | ||
| src?: undefined; | ||
| dest?: undefined; | ||
| } | { | ||
| src: string; | ||
| dest: string; | ||
| handle?: undefined; | ||
| })[]; | ||
| framework: { | ||
| slug: string; | ||
| version: string; | ||
| }; | ||
| } | { | ||
| routes: ({ | ||
| src: string; | ||
| dest: string; | ||
| methods: string[]; | ||
| } | { | ||
| handle: string; | ||
| src?: undefined; | ||
| dest?: undefined; | ||
| } | { | ||
| src: string; | ||
| dest: string; | ||
| handle?: undefined; | ||
| })[]; | ||
| framework: { | ||
| slug: string; | ||
| version: string; | ||
| }; | ||
| additionalFolders: string[]; | ||
| additionalDeps: string[]; | ||
| }>; | ||
| //#endregion | ||
| //#region src/index.d.ts | ||
@@ -8,2 +106,2 @@ declare const version = 2; | ||
| //#endregion | ||
| export { build, prepareCache, version }; | ||
| export { type CervelBuildOptions, type CervelServeOptions, type PathOptions, build, build$1 as cervelBuild, serve as cervelServe, findEntrypoint, getBuildSummary, introspectApp, nodeFileTrace, prepareCache, srvxOptions, version }; |
+23
-7
| { | ||
| "name": "@vercel/backends", | ||
| "version": "0.0.24", | ||
| "version": "0.0.25", | ||
| "license": "Apache-2.0", | ||
@@ -13,3 +13,8 @@ "main": "./dist/index.mjs", | ||
| ".": "./dist/index.mjs", | ||
| "./package.json": "./package.json" | ||
| "./package.json": "./package.json", | ||
| "./introspection/loaders/cjs": "./dist/introspection/loaders/cjs.cjs", | ||
| "./introspection/loaders/esm": "./dist/introspection/loaders/esm.mjs", | ||
| "./introspection/loaders/hooks": "./dist/introspection/loaders/hooks.mjs", | ||
| "./introspection/loaders/rolldown-esm": "./dist/introspection/loaders/rolldown-esm.mjs", | ||
| "./introspection/loaders/rolldown-hooks": "./dist/introspection/loaders/rolldown-hooks.mjs" | ||
| }, | ||
@@ -25,6 +30,17 @@ "repository": { | ||
| "dependencies": { | ||
| "@vercel/nft": "1.3.0", | ||
| "execa": "3.2.0", | ||
| "fs-extra": "11.1.0", | ||
| "@vercel/cervel": "0.0.11", | ||
| "@vercel/introspection": "0.0.10" | ||
| "oxc-transform": "0.111.0", | ||
| "path-to-regexp": "8.3.0", | ||
| "resolve.exports": "2.0.3", | ||
| "rolldown": "1.0.0-rc.1", | ||
| "srvx": "0.8.9", | ||
| "tsx": "4.21.0", | ||
| "zod": "3.22.4", | ||
| "@vercel/build-utils": "13.2.16" | ||
| }, | ||
| "peerDependencies": { | ||
| "typescript": "^4.0.0 || ^5.0.0" | ||
| }, | ||
| "devDependencies": { | ||
@@ -35,9 +51,8 @@ "@types/express": "5.0.3", | ||
| "@types/node": "20.11.0", | ||
| "execa": "3.2.0", | ||
| "hono": "4.10.1", | ||
| "jest-junit": "16.0.0", | ||
| "tsdown": "0.16.3", | ||
| "typescript": "4.9.5", | ||
| "vite": "^5.1.6", | ||
| "vitest": "^2.0.1", | ||
| "@vercel/build-utils": "13.2.16" | ||
| "vitest": "^2.0.1" | ||
| }, | ||
@@ -49,2 +64,3 @@ "module": "./dist/index.mjs", | ||
| "vitest-run": "vitest -c ../../vitest.config.mts", | ||
| "vitest": "tsdown && vitest", | ||
| "vitest-unit": "glob --absolute 'test/unit.*test.ts'", | ||
@@ -51,0 +67,0 @@ "type-check": "tsc --noEmit" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
10
-9.09%19
280%102356
-95.79%12
300%2604
-97.71%20
Infinity%3
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed