Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use eventsource javascript package #12890

Closed
mythz opened this issue Mar 12, 2017 · 1 comment
Closed

Can't use eventsource javascript package #12890

mythz opened this issue Mar 12, 2017 · 1 comment
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@mythz
Copy link

mythz commented Mar 12, 2017

The eventsource package is a pure JavaScript implementation of the EventSource client which aims to be W3C compatible and provides a simple solution for real-time notifications over http which is especially useful in mobile apps.

Funnily EventSource works when debugging JS Remotely as it's able to use the built-in EventSource in Chrome, but doesn't work when debugging is disabled as it fails with:

Can't find variable: EventSource

Then trying to import the JavaScript eventsource:

yarn add eventsource 

fails with similar results in npm or yarn when trying to import it:

global.EventSource = require('eventsource');

iOS displays an error page with Unable to resolve module {module_name} from ../node_modules/eventsource/lib/eventsource.js. First it fails with url module, which I then import with:

yarn add url

Then it continues with the same error page for the following core modules used by eventsource:

  • events
  • https
  • http
  • util

Then when all these modules are added if ends up failing with Unable to resolve module https... even though it's already added. This exact failing sequence also happened before I had yarn installed.

Solution

The error is due to failing to load core node.js modules so it looks like it's either a module loading error or react-native doesn't support these core node.js modules. It would help with compatibility of other packages if react-native had built-in support for these core modules.

Additional Information

  • React Native version: latest react-native 0.42.0
  • Platform: iOS
  • Operating System: OSX 10.12.3 (Sierra)
@mythz
Copy link
Author

mythz commented Mar 14, 2017

There are 2 other Event Source implementations that work with React Native:

@mythz mythz closed this as completed Mar 14, 2017
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants