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

Is it possible to use replacement module with Packager? #4018

Closed
zsszatmari opened this issue Nov 9, 2015 · 5 comments
Closed

Is it possible to use replacement module with Packager? #4018

zsszatmari opened this issue Nov 9, 2015 · 5 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@zsszatmari
Copy link

Hi!

browserify can do the following: I specify this in package.json:

"browser": {
    "request": "browser-request"
  }

and every module which depends on request will use browser-request module instead. Is similar possible with Packager?
(btw I would happily rtfm but couldn't find a documentation for packager)

Thank You!

@ide
Copy link
Contributor

ide commented Nov 9, 2015

Yes, "browser" field should already be honored. There's a PR out to add a "react-native" field: #2208

@zsszatmari
Copy link
Author

Thanks for the quick answer! However, I can't seem to make it work. For example I have a module in my package.json and hence node_modules which depends on 'request' which depends on 'net'. I would like it to require browser-request instead, but it's still Requiring unknown module "net" :/
(Restarted packager, no help)

(browserify, on the other hand, does this)

@siuying
Copy link

siuying commented Jan 8, 2016

react native packager do not seems to do it on dependencies? if it is just at top level, it would not have much use as I can always use require("react-native-level-fs") instead of require("fs").

@vespakoen
Copy link

It does do it recursively, however, some packages expect to be run after being "browserified", and depend on node modules that browserify will automatically replace / shim with a browser compatible version.

At the moment you can use: https://github.com/mvayngrib/rn-nodeify to "hack" the package.json's of your sub-node_modules to add in the necessary replacements

@jsierles
Copy link
Contributor

Closing this out in favor of discussion on the meta-issue at #6253.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 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

6 participants