fix: resolver.resolveRequest is always undefined #1982
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
I just upgraded to react-native 0.72.0 in our project and found out that
resolver.resolveRequest
from the project config is always getting overridden by thegetOverrideConfig
function. The PR helps fix the issue so that we are able to define our customresolveRequest
functions.For example here's the
metro.config.js
file of our project where we are usingresolveRequest
. This was working in RN 0.71.11 but stopped working after upgrading to 0.72.0.The problematic code is here:
cli/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts
Lines 32 to 36 in a1cc798
and then the
undefined value replaces the project config value for
resolveConfig here:cli/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts
Lines 120 to 123 in a1cc798
Test Plan:
To test the issue, create a new react-native 0.72.0 project & replace contents of
metro.config.js
with the following:Without the fix
"Resolve Request Received"
never get's logged sinceresolver.resolveRequest
is always undefined in the final config used by metro bundler.