Skip to content

Expose Gradient via @ankhorage/zora/gradient so expo-linear-gradient stays optional #260

Description

@artiphishle

Problem

Gradient currently imports expo-linear-gradient directly:

import { LinearGradient } from 'expo-linear-gradient';

and ZORA also exports Gradient from the root package:

export { Gradient } from './components/gradient';

That means consumers that broadly import from @ankhorage/zora can cause the Gradient module graph to be evaluated, even when they do not intentionally use Gradient.

For native Expo consumers, this makes expo-linear-gradient effectively required even though it is declared as an optional peer dependency.

Desired direction

Make Gradient truly optional by moving the runtime/native dependency behind a dedicated subpath export:

import { Gradient } from '@ankhorage/zora/gradient';

The package root should avoid importing or re-exporting modules that require optional native dependencies.

Proposed design

  1. Add an export subpath:
{
  "exports": {
    ".": { ... },
    "./gradient": {
      "react-native": "./src/components/gradient/index.ts",
      "browser": "./src/components/gradient/index.ts",
      "types": "./dist/components/gradient/index.d.ts",
      "import": "./dist/components/gradient/index.js",
      "default": "./dist/components/gradient/index.js"
    }
  }
}
  1. Remove Gradient value export from root src/index.ts, or keep only type-level exports if TypeScript/build output can guarantee no runtime import.

  2. Update docs/examples to import Gradient from:

import { Gradient } from '@ankhorage/zora/gradient';
  1. Keep expo-linear-gradient as an optional peer dependency, but document that it is required for the @ankhorage/zora/gradient subpath.

  2. Consider adding metadata for optional-native components so app generators can install native packages only when a manifest/component actually uses the component.

Acceptance criteria

  • Importing from @ankhorage/zora root does not evaluate/import expo-linear-gradient.
  • Gradient remains available from @ankhorage/zora/gradient.
  • Apps that do not import/use Gradient do not need expo-linear-gradient installed.
  • Apps that do import/use @ankhorage/zora/gradient get a clear peer dependency requirement.
  • Typecheck/build/tests pass.

Notes

This is the architectural ZORA-side fix. The immediate generated-app unblock is tracked separately in ankhorage4, where generated apps should include expo-linear-gradient as long as root ZORA imports still make it effectively required.

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