Skip to content

Declare event-target-shim as a dependency (missing on React Native 0.80+) - #118

Open
andrejtomic wants to merge 1 commit into
splitio:developmentfrom
andrejtomic:fix/declare-event-target-shim
Open

andrejtomic wants to merge 1 commit into
splitio:developmentfrom
andrejtomic:fix/declare-event-target-shim

Conversation

@andrejtomic

Copy link
Copy Markdown

React Native SDK

What did you accomplish?

  • src/platform/EventSource/EventSourceBase.ts does require('event-target-shim'), but the package doesn't declare event-target-shim as a dependency. It has only resolved because react-native depended on it (^5.0.1) and package managers hoisted that copy.
  • react-native dropped that dependency in 0.80 (0.79 is the last version that has it). On 0.80+ the module is missing unless something else happens to pull it in, and Metro fails with Unable to resolve module event-target-shim when it bundles the EventSource polyfill.
  • This PR declares event-target-shim@^5.0.1 in dependencies, the same range React Native used. The code uses v5's default-export EventTarget class, so 6.x is out of scope. The lockfile only adds the specifier and drops dev: true from the entry that was already there. The resolved version doesn't change.
  • It also updates the stale // Package included by react-native comment.

How do we test the changes introduced in this PR?

Reproduce on development / 1.5.0 from npm:

mkdir repro && cd repro && npm init -y
npm i --ignore-scripts @splitsoftware/splitio-react-native@1.5.0 react-native@0.88.0 react@19
node -e "require.resolve('event-target-shim', { paths: [require('path').dirname(require.resolve('@splitsoftware/splitio-react-native/package.json'))] })"
# => Error: Cannot find module 'event-target-shim'

With this branch, event-target-shim gets installed alongside the SDK and resolves. npm run check, npm test and npm run build pass.

Extra Notes

  • I didn't add a unit test. This repo's dev install uses react-native@0.72, which still brings event-target-shim in, so a test here would pass with or without the fix.
  • I didn't touch CHANGES.txt so it won't conflict with the open release PR (Prepare release v1.6.0 #115). A suggested entry: Bugfix - Declared event-target-shim as a dependency, required by the EventSource polyfill, since React Native 0.80+ no longer provides it.

EventSourceBase requires event-target-shim, but the package did not
declare it and relied on react-native's transitive copy. React Native
stopped depending on event-target-shim in 0.80, so on 0.80+ apps the
module only resolves by accident (or not at all), and Metro fails with
"Unable to resolve module event-target-shim".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant