Skip to content

[Bug]: Code fails to bundle with API routes #310

@Nezz

Description

@Nezz

Which Platforms?

Both

Which React Native Version?

0.81.5

Which @braze/react-native-sdk SDK version?

18.0.0

Repro Rate

100%

Steps To Reproduce

The code bunding fails when a project has Expo API Routes.

Minimal repro project: https://github.com/Nezz/expo-repro/tree/repro/Braze

Steps:

  1. Run bun install
  2. Run bun expo export:embed --eager --platform ios --dev false

Expected Behavior

The code bunding should work

Actual Incorrect Behavior

Bundling the code fails:

Error: Importing native-only module "react-native/Libraries/Utilities/codegenNativeComponent" on web from: node_modules/@braze/react-native-sdk/src/specs/BrazeBannerViewNativeComponent.ts

Import stack:

 node_modules/@braze/react-native-sdk/src/specs/BrazeBannerViewNativeComponent.ts
 | import "react-native/Libraries/Utilities/codegenNativeComponent"
           ^ Importing react-native internals is not supported on web.

 node_modules/@braze/react-native-sdk/src/ui/braze-banner-view.js
 | import "../specs/BrazeBannerViewNativeComponent"

 node_modules/@braze/react-native-sdk/src/braze.js
 | import "./ui/braze-banner-view"

 node_modules/@braze/react-native-sdk/src/index.js
 | import "./braze"

 app/(tabs)/index.tsx
 | import "@braze/react-native-sdk"

Verbose Logs

Additional Information

It'd be nice to provide a polyfill for web for this to work out of the box

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions