Skip to content

[Feature] Move helpers from commerce-sdk-isomorphic to commerce-sdk-react #199

@FerVillanuevas

Description

@FerVillanuevas

Problem Statement
The commerce-sdk-isomorphic library currently includes helper functions that break React Native/Expo compatibility due to Node.js crypto dependencies, preventing the library from being truly isomorphic.
React Native/Expo Compatibility Issues
1. Expo SDK 52: Async imports are not supported, causing issues with crypto module loading
2. Expo SDK 53: While async imports are now supported, Node.js crypto library remains unsupported in React Native environments
3. Bundle size: Applications that only need the API clients are forced to include crypto dependencies

Current Impact

The helpers in commerce-sdk-isomorphic include authentication and utility functions that rely on Node.js crypto functionality, making the core SDK incompatible with React Native environments despite being labeled “isomorphic.”
Proposed Solution
Move helpers to commerce-sdk-react
The commerce-sdk-react library is the ideal location for these helpers because:
1. Architectural Fit: commerce-sdk-react already handles authentication complexity and token management
2. Target Audience: Authentication helpers are primarily used in React/React Native applications
3. Existing Infrastructure: The library already provides React-specific abstractions for Commerce API integration
4. Separation of Concerns: API client logic should be separate from authentication logic

Benefits of This Approach

  1. True Isomorphic Compatibility
    • commerce-sdk-isomorphic becomes truly isomorphic, working in browsers, Node.js, and React Native
    • No crypto dependencies in the core API clients
    • Works with both Expo SDK 52 (no async imports) and SDK 53+ (async imports supported)

  2. Improved Developer Experience
    • Smaller bundles: Applications using only API clients don’t include unnecessary crypto code
    • Better tree-shaking: Unused authentication helpers can be eliminated
    • React-specific optimizations: Helpers can be optimized for React/React Native environments

  3. Maintenance Benefits
    • Isolated issues: Crypto-related problems don’t affect core API functionality
    • Independent updates: Authentication helpers can be updated without affecting API clients
    • Platform-specific implementations: React Native crypto can be handled appropriately

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