The current public API (lib/index.ts) accepts a raw string[] mimicking CLI argv:
export async function exec(argv: string[])
This forces programmatic consumers to construct CLI-style argument arrays, which is error-prone, untyped, and undiscoverable:
// Current — no type safety, easy to get wrong
await exec(['project/', '--targets', 'node22-linux-x64', '--sea', '-C', 'Brotli']);
Proposal
Introduce a typed options interface and an overload or new entry point:
interface PkgOptions {
input: string;
targets?: string[];
output?: string;
outputPath?: string;
compress?: 'None' | 'Brotli' | 'GZip';
sea?: boolean;
debug?: boolean;
bytecode?: boolean;
// ...
}
export async function exec(options: PkgOptions): Promise<void>;
// Keep backward compat:
export async function exec(argv: string[]): Promise<void>;
Scope
- Define
PkgOptions interface (reuse/extend existing internal types from lib/types.ts)
- Support both
string[] (backward compat) and PkgOptions overloads
- Export the types from the package entry point
- Document the new API in the docs site
Part of #235
The current public API (
lib/index.ts) accepts a rawstring[]mimicking CLI argv:This forces programmatic consumers to construct CLI-style argument arrays, which is error-prone, untyped, and undiscoverable:
Proposal
Introduce a typed options interface and an overload or new entry point:
Scope
PkgOptionsinterface (reuse/extend existing internal types fromlib/types.ts)string[](backward compat) andPkgOptionsoverloadsPart of #235