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

support resolve.alias ala webpack #5917

Closed
jacobrosenthal opened this issue Feb 14, 2016 · 11 comments
Closed

support resolve.alias ala webpack #5917

jacobrosenthal opened this issue Feb 14, 2016 · 11 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@jacobrosenthal
Copy link
Contributor

The big feature still missing from react packager is the ability to shim one module for another. You might know this in browserify as transforms. I was previously using react-native-webpack-server but that appears to be dying out so Im hoping to track support for this here.

@facebook-github-bot
Copy link
Contributor

Hey jacobrosenthal, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@satya164
Copy link
Contributor

cc @martinbigio

@grabbou
Copy link
Contributor

grabbou commented Feb 15, 2016

Does this solve your issue by any chance? https://medium.com/@grabbou/a-cure-for-relative-requires-in-react-native-2b263cecf0f6

@jacobrosenthal
Copy link
Contributor Author

Sadly not. What resolve.alias does is find all packages that, say, require('noble') and swap out that dependency for another, say react-native-ble. In this way we can shim existing api surfaces which already have an ecosystem built on top of them, and bring all that with us to react native.

@martinbigio
Copy link
Contributor

I can see how this could be useful for the community but I think we want to be very cautious with the API call we add. @jacobrosenthal would be great if you could give a couple of examples and post on product pains to get a sense of how many people would love to have this.

cc @cpojer

@vespakoen
Copy link

This is fixed now that react-native supports the "browser" and "react-native" field (that works as the "browser" field but gets precedence)

https://github.com/defunctzombie/package-browser-field-spec

@jacobrosenthal
Copy link
Contributor Author

Amazing, Ill check soon. What version was that support added?

@cpojer
Copy link
Contributor

cpojer commented Mar 2, 2016

I'd be happy to support this inside of node-haste, see https://github.com/facebook/node-haste – once we have that, we can integrate it both into Jest and packager. Does anyone want to work on sending a PR for node-haste? :)

@vespakoen
Copy link

It is already in node-haste! (I think this functionality got added in version 0.20, was still in react-native back then)

https://github.com/facebook/node-haste/blob/master/src/Package.js#L94

Btw, if you like even more browserify compatibility, support / improve my PR:

facebookarchive/node-haste#46

EDIT Turns out it is present since 0.17

@mkonicek
Copy link
Contributor

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/support-resolvealias-ala-webpack

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless
Product Pains has been very useful in highlighting the top bugs and feature requests:
https://productpains.com/product/react-native?tab=top

Also, if this issue is a bug, please consider sending a pull request with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

c-h- added a commit to c-h-/react-native-macos that referenced this issue Feb 11, 2017
This commit makes it possible to add a `react-native-macos` field to package.json that functions the same way as `react-native` to shim one-level deep requires/imports. See facebook/react-native#5917 for details of `browser` and `react-native fields`.

This commit makes it possible to share code more broadly between react native platforms. For example, take the following package.json field:
```
"react-native-macos": { "react-native": "react-native-macos" }
```
With this set our components can import from react-native rather than react-native-macos, allowing code sharing between react native platforms more easily.
@sanketsahu
Copy link

It works well with this .babelrc plugin:
https://reactnatve.wordpress.com/2016/06/16/alias-in-react-native/

@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

10 participants