diff --git a/.changeset/lazy-load-xdg-paths.md b/.changeset/lazy-load-xdg-paths.md new file mode 100644 index 0000000..b57c56a --- /dev/null +++ b/.changeset/lazy-load-xdg-paths.md @@ -0,0 +1,5 @@ +--- +"@vercel/sandbox": patch +--- + +Load CLI auth path discovery only when accessing the local auth configuration. diff --git a/packages/vercel-sandbox/src/auth/file.ts b/packages/vercel-sandbox/src/auth/file.ts index 22f0fdd..269947e 100644 --- a/packages/vercel-sandbox/src/auth/file.ts +++ b/packages/vercel-sandbox/src/auth/file.ts @@ -1,10 +1,12 @@ import path from "node:path"; import fs from "node:fs"; +import { createRequire } from "node:module"; import { homedir } from "node:os"; -import XDGAppPaths from "xdg-app-paths"; import { z } from "zod"; import { json } from "./zod.js"; +type XDGAppPathsFactory = typeof import("xdg-app-paths"); + const ZodDate = z.number().transform((seconds) => new Date(seconds * 1000)); const AuthFile = z.object({ @@ -38,6 +40,8 @@ const getGlobalPathConfig = (): string => { return process.env.VERCEL_AUTH_CONFIG_DIR; } + const require = createRequire(import.meta.url); + const XDGAppPaths = require("xdg-app-paths") as XDGAppPathsFactory; const vercelDirectories = XDGAppPaths("com.vercel.cli").dataDirs(); const possibleConfigPaths = [