Skip to content

feat: typed options object for the Node.js API #242

@robertsLando

Description

@robertsLando

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions