Skip to content

Avoid postinstall by using optionalDependencies for each platform #104

@sverrejoh

Description

@sverrejoh

Problem

The azureauth package downloads its binary via a postinstall script. This doesn't work with:

  • pnpm 10+ - blocks lifecycle scripts by default for security
  • yarn PnP - not recommended due to unplugging behavior
  • --ignore-scripts - when lifecycle scripts are disabled for security
  • Network issues - downloads outside the package fetch stage miss retry mechanisms, caching, and mirrors

Proposed Solution

Use npm's optionalDependencies with os and cpu fields - the same pattern used by esbuild, SWC, and sharp.

  1. Create platform-specific packages (@azureauth/darwin-arm64, etc.)
  2. List them as optionalDependencies in the main package
  3. Package managers automatically install only the matching platform
  4. Postinstall becomes a fallback for unsupported platforms

References

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