-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Comments
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.
|
cc @martinbigio |
Does this solve your issue by any chance? https://medium.com/@grabbou/a-cure-for-relative-requires-in-react-native-2b263cecf0f6 |
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. |
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 |
This is fixed now that react-native supports the "browser" and "react-native" field (that works as the "browser" field but gets precedence) |
Amazing, Ill check soon. What version was that support added? |
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? :) |
It is already in node-haste! (I think this functionality got added in version https://github.com/facebook/node-haste/blob/master/src/Package.js#L94 Btw, if you like even more browserify compatibility, support / improve my PR: EDIT Turns out it is present since 0.17 |
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. Also, if this issue is a bug, please consider sending a pull request with a fix. |
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.
It works well with this .babelrc plugin: |
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.
The text was updated successfully, but these errors were encountered: