/** * Loading a heavy dependency only if the tool that needs it is actually used. * * Eleven packages were imported at module top level and shipped in nobody's * install -- `typescript`, `@babel/parser`, `@typescript-eslint/typescript-estree`, * `prettier`, `react` and others were devDependencies or absent entirely. On a * developer's machine they resolve out of node_modules and everything looks * fine. On a user's machine `npm i -g` installs only `dependencies`, so around * twelve advertised MCP tools threw * * Cannot find package 'typescript' imported from ... * * the moment anything touched them. Dead on arrival, with an error that tells * the user nothing about what to do. * * The small dependencies are now declared and simply work. The heavy ones -- * a TypeScript compiler is 20 MB, and most sessions never run a code-analysis * tool -- load on first use through here, so: * * - installing the package stays cheap for the people who never need them * - a tool that cannot run says WHICH package is missing and the exact * command that fixes it * - the failure happens when the tool is called, not when it is imported, so * one missing optional package cannot take the whole server down * * `cache-compression` already did this correctly for lz4/zstd/snappy. This is * that pattern, made shared and given a decent error message. */ export declare class MissingOptionalDependency extends Error { readonly packageName: string; readonly toolName: string; readonly why: string; constructor(packageName: string, toolName: string, why: string); } /** * Imports an optional package, or explains precisely why it could not. * * @param packageName what to import, exactly as it would be typed into npm * @param toolName the tool asking, so the message names something the user * recognises rather than a file path * @param why one line on what the package is for, so the user can * decide whether they want it at all */ export declare function optionalDependency(packageName: string, toolName: string, why: string): Promise; /** Whether an optional package is available, without throwing. */ export declare function hasOptionalDependency(packageName: string): Promise; //# sourceMappingURL=optional-dependency.d.ts.map