Giter VIP home page Giter VIP logo

Comments (8)

gaearon avatar gaearon commented on March 29, 2024 1

Isn't module system supposed to take browser “redirects” into account as specified in package.json? I think it's the reason I didn't have this problem with Webpack:

(from superagent's package.json:)

  "browser": {
    "./lib/node/index.js": "./lib/client.js",
    "emitter": "component-emitter",
    "reduce": "reduce-component"
  },
  "main": "./lib/node/index.js",

React Native's bundler doesn't seem to look at these.

Which triggers another question: why does RN use its own bundler instead of Webpack or Browserify? There may be other potential issues lurking in there, already solved by existing bundlers. There is an entire ecosystem of transformers, including support for AMD or ES6 or transpile-to-JS languages.

Shouldn't we leverage this by default?

from react-native.

vjeux avatar vjeux commented on March 29, 2024

We're still unclear about this. We're trying to be very deliberate in the dependencies that we add inside of core.

You can use fetch, the new w3c api in order to do data fetching. We also have xhr implemented.

For node modules like events, this is unclear. I wish that we could push events to npm instead of having it inside of react native directly.

from react-native.

vjeux avatar vjeux commented on March 29, 2024

Would love to get your point of view on this subject

from react-native.

nick avatar nick commented on March 29, 2024

I had a little more luck by using the browser build of superagent but it seems there's more of xhr that hasn't been ported yet that trips superagent up. Personally I'd love to see superagent supported as I already use it on the client and server and would be great if all that code could be shared. I'll see if I can work on Libraries/XMLHttpRequest/XMLHttpRequest.ios.js to get superagent working.

from react-native.

amasad avatar amasad commented on March 29, 2024

I answered this in another thread #5 (comment)

from react-native.

lazywei avatar lazywei commented on March 29, 2024

This is still a problem, isn't it? Would RN packager plan to fix this? Thanks 👍

from react-native.

philipshurpik avatar philipshurpik commented on March 29, 2024

Hi!
You can try 'superagent/lib/client' but you need to modify require statements at the top of file:
var Emitter = require('component-emitter');
var reduce = require('reduce-component');
Because React Native doesn't correctly handle 'browser' section in package.json.

Also you can try my fork that is work with React Native:
https://github.com/philipshurpik/superagent
It has some other little fixes... Mainly default content type fix - set "application/json" as default, because react native xhr request doesn't correctly handle it.

from react-native.

amasad avatar amasad commented on March 29, 2024

The packager now looks at the browser field. superagent should be usable once they publish a new version following this PR ladjs/superagent#621 which just makes it not depend on a location object on the global object.

from react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.