Repository navigation
Resolver: Extract redirectPackageSubpath from redirectModulePath - #2044
Merged
Merged
Conversation
## Summary `redirectModulePath` asks `context.getPackageForModule` for the package containing a module path, then applies that package's `mainFields` redirections (the "browser" spec) to the module's package-relative path. This splits the second half out as `redirectPackageSubpath`, for callers that already know the containing package. `redirectModulePath` delegates to it for relative and absolute paths and behaves exactly as before; bare specifiers are unchanged. #1945 uses it to look up the package of a directory's files once and apply it to every extension candidate, instead of calling `redirectModulePath` per candidate. ## Test plan ``` yarn jest packages/metro-resolver packages/metro/src/DeltaBundler/__tests__/resolver-test.js yarn flow check ``` Changelog: Internal
robhogan
added this pull request to stack #2045
October 9, 2026 15:34
Contributor
There was a problem hiding this comment.
馃煝 Approval recommended
The extraction preserves existing behavior and introduces no unresolved issues.
0 open findings
What changed in this PR
Extracts package-subpath redirection logic for reuse while preserving existing resolver behavior.
Changes:
- Adds
redirectPackageSubpath. - Delegates relative and absolute path handling to the new helper.
| File | Description |
|---|---|
packages/鈥媘etro-resolver/鈥媠rc/鈥婸ackageResolve.js |
Extracts reusable package-relative redirect logic. |
馃 Review effort: Balanced
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
robhogan
marked this pull request as ready for review
October 13, 2026 10:35
huntie
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
redirectModulePathaskscontext.getPackageForModulefor the package containing a module path, then applies that package'smainFieldsredirections (the "browser" spec) to the module's package-relative path. This splits the second half out asredirectPackageSubpath, for callers that already know the containing package.redirectModulePathdelegates to it for relative and absolute paths and behaves exactly as before; bare specifiers are unchanged.#1945 uses it to look up the package of a directory's files once and apply it to every extension candidate, instead of calling
redirectModulePathper candidate.Changelog: Internal
Test plan
A pure refactor, covered by the existing resolver tests.