Skip to content

Remove Expo peer dependency — support bare React Native projects #11

@blick

Description

@blick

Context

We would like to use this SDK in a bare React Native project, but expo is listed as a peer dependency, which prevents this.


Investigation findings

After a full investigation including runtime testing, the Expo dependency is deeper than initially apparent. There are two layers:

1. JS layer — requireNativeModule from expo

src/CookieInformationRNSDKModule.ts imports requireNativeModule from expo to access the native module. Replacing this with NativeModules from react-native is technically straightforward, but it does not work as long as the native modules are built on ExpoModulesCore — because ExpoModulesCore registers modules in its own system, separate from the classic React Native bridge. NativeModules.CookieInformationRNSDK returns null at runtime.

2. Native layer — ExpoModulesCore (the real dependency)

Both native implementations extend Expo's module system:

  • iOS (ios/CookieInformationRNSDKModule.swift): import ExpoModulesCore, extends Module
  • Android (android/src/main/java/expo/modules/mobileconsentssdk/CookieInformationRNSDKModule.kt): package expo.modules.mobileconsentssdk, uses Expo module registration

This is the root cause. expo-modules-core must be present as a native dependency regardless of what the JS layer does.


What a real fix requires

To remove the Expo peer dependency entirely, both native modules need to be rewritten using the standard React Native bridge:

  • iOS: Replace ExpoModulesCore with RCTBridgeModule / RCTEventEmitter
  • Android: Replace Expo module registration with a standard ReactPackage + ReactContextBaseJavaModule

The JS layer change (requireNativeModuleNativeModules) follows naturally once the native side is updated.


Current workaround

None — bare React Native projects without expo-modules-core cannot use this SDK today.


Would you be open to rewriting the native modules to use the standard React Native bridge?

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