Skip to content

[Packager] Global require replace (ala webpack's resolve.alias and browserify's builtins) #6253

@vespakoen

Description

@vespakoen

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. support resolve.alias ala webpack #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. Compatibility: node packages depending on V8 can't function in react-native iOS #5881
    Twilio client uses the "crypto" browserify builtin

  3. Using NodeJS modules packages via Browserify? #5555
    Somebody that wants to use builtins

  4. "Error: Requiring module "BatchedBridge" which threw an exception" after upgrade to 0.14.1 #4022 and "ReferenceError: Can't find variable: process" after update to 0.14.2 #4098
    Requiring a package that expects process to be present (maybe already fixed by the addition of the "browser" and "react-native" field)

  5. Is it possible to use replacement module with Packager? #4018
    Someone trying to use (a package that depends on) the "net" package

  6. [Packager] should use compatible versions of node core modules #1871
    More people wanting node-ish support in react-native

  7. packager assume that every method named require is module loader function #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.

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