React-native: [Packager] Global require replace (ala webpack's resolve.alias and browserify's builtins)

Created on 3 Mar 2016  路  5Comments  路  Source: facebook/react-native

I am working on making modules that depend on browserify's builtins compatible with react-native.

My current pull request over at node-haste supports the browserify builtins but unfortunately node-haste is depended upon by other packages, so I am looking for a more generic solution.

The first solution that came to my mind is to support a config option with "global replacements".
This way, we could tell node-haste to replace / alias packages.

How are we feeling about supporting this?

To me this seems an obvious problem that we should fix since it will make a lot more packages compatible with react-native, the most important win being (imo) having access to all the streaming libraries.

Related issues

1) https://github.com/facebook/react-native/issues/5917
Fixed, But only works on a per-module level, this issue is for replacing modules on a global level, allowing us to "imitate" browserify's builtins.

2) https://github.com/facebook/react-native/issues/5881
Twilio client uses the "crypto" browserify builtin

3) https://github.com/facebook/react-native/issues/5555
Somebody that wants to use builtins

4) https://github.com/facebook/react-native/issues/4022 and https://github.com/facebook/react-native/issues/4098
Requiring a package that expects process to be present (maybe already fixed by the addition of the "browser" and "react-native" field)

5) https://github.com/facebook/react-native/issues/4018
Someone trying to use (a package that depends on) the "net" package

6) https://github.com/facebook/react-native/issues/1871
More people wanting node-ish support in react-native

7) https://github.com/facebook/react-native/issues/5988
Somebody trying to use a library that depends on the "stream" builtin

There are probably a bunch more out there but this is what I could collect with a couple of searches.

Locked Discussion

Most helpful comment

All 5 comments

+1

+1000

+1

This definitely sounds useful. As an issue, this seems like a duplicate of the product pains link, so I'm going to close this issue in favor of that.

Was this page helpful?
0 / 5 - 0 ratings