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

feat: allow OOT platforms to use custom resolver.resolveRequest #41697

Conversation

okwasniewski
Copy link
Contributor

@okwasniewski okwasniewski commented Nov 29, 2023

Summary:

Currently, when we have an additional platform in react-native.config.js, users cannot use custom resolver.resolveRequest functions as they are overwritten by reactNativePlatformResolver. Goal of this PR is to allow OOT platforms to use additional custom resolvers besides remapping react native imports.

Changelog:

[GENERAL] [FIXED] - Allow Out Of Tree platforms to pass custom resolvers

Test Plan:

  1. Add additional platform in react-native.config.js
  2. Pass custom resolver to metro.config.js:
resolveRequest: (context, moduleName, platform) => {
      console.log('resolveRequest', moduleName, platform);
      return context.resolveRequest(context, moduleName, platform);
 }
  1. Check if user's resolveRequest function is called.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Nov 29, 2023
@okwasniewski
Copy link
Contributor Author

cc: @huntie

@thymikee
Copy link
Contributor

thymikee commented Nov 29, 2023

This code used to be in RN CLI and the fix looks good from my side.

@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link

This pull request was successfully merged by @okwasniewski in 4ccd6e1.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions bot added the Merged This PR has been merged. label Nov 29, 2023
Othinn pushed a commit to Othinn/react-native that referenced this pull request Jan 9, 2024
…book#41697)

Summary:
Currently, when we have an additional platform in `react-native.config.js`, users cannot use custom `resolver.resolveRequest` functions as they are overwritten by `reactNativePlatformResolver`. Goal of this PR is to allow OOT platforms to use additional custom resolvers besides remapping react native imports.

## Changelog:

[GENERAL] [FIXED] - Allow Out Of Tree platforms to pass custom resolvers

Pull Request resolved: facebook#41697

Test Plan:
1. Add additional platform in `react-native.config.js`
2. Pass custom resolver to `metro.config.js`:

```js
resolveRequest: (context, moduleName, platform) => {
      console.log('resolveRequest', moduleName, platform);
      return context.resolveRequest(context, moduleName, platform);
 }
```
3. Check if user's `resolveRequest` function is called.

Reviewed By: huntie

Differential Revision: D51659721

Pulled By: robhogan

fbshipit-source-id: 952589b59a6fa34e9406d36c900be53a7c1a79c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants