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

Use resolvePackage instead of resolveModulePath in resolveHasteName #1136

Closed
wants to merge 2 commits into from

Conversation

kraenhansen
Copy link
Contributor

Summary

This fixes #1128 by calling the resolvePackage instead of resolveModulePath in resolveHasteName.
Only resolvePackage has the code to resolve package "exports" and it calls resolveModulePath as a fallback.

Test plan

I've added a failing test which passed as the fix got implemented.

@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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Nov 10, 2023
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e2d6419) 83.09% compared to head (3cef847) 83.09%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1136   +/-   ##
=======================================
  Coverage   83.09%   83.09%           
=======================================
  Files         206      206           
  Lines       10549    10549           
  Branches     2619     2619           
=======================================
  Hits         8766     8766           
  Misses       1783     1783           
Files Coverage Δ
packages/metro-resolver/src/resolve.js 97.51% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@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.

@robhogan
Copy link
Contributor

Thanks @kraenhansen - this LGTM (and @huntie), importing to run it through internal CI.

FWIW, enableHastePackages is default-off from Metro 0.79, so hopefully these cases of unintentionally resolving via Haste should go away, but this is a good correctness fix nonetheless.

@facebook-github-bot
Copy link
Contributor

@robhogan merged this pull request in 7b1eb60.

robhogan pushed a commit that referenced this pull request Jan 9, 2024
…ame` (#1136)

Summary:
This fixes #1128 by calling the `resolvePackage` instead of `resolveModulePath` in `resolveHasteName`.
Only `resolvePackage` has the code to resolve package "exports" and it calls `resolveModulePath` as a fallback.

Changelog: [Experimental] When enabled, the `"exports"` field is now considered for Haste packages (which could include local monorepo packages)

Pull Request resolved: #1136

Test Plan: I've added a failing test which passed as the fix got implemented.

Reviewed By: huntie

Differential Revision: D51346769

Pulled By: robhogan

fbshipit-source-id: 8a003d5b147b73d344365db7cff8187ff946013d
@robhogan robhogan mentioned this pull request Jan 9, 2024
robhogan pushed a commit that referenced this pull request Jan 9, 2024
…ame` (#1136)

Summary:
This fixes #1128 by calling the `resolvePackage` instead of `resolveModulePath` in `resolveHasteName`.
Only `resolvePackage` has the code to resolve package "exports" and it calls `resolveModulePath` as a fallback.

Changelog: [Experimental] When enabled, the `"exports"` field is now considered for Haste packages (which could include local monorepo packages)

Pull Request resolved: #1136

Test Plan: I've added a failing test which passed as the fix got implemented.

Reviewed By: huntie

Differential Revision: D51346769

Pulled By: robhogan

fbshipit-source-id: 8a003d5b147b73d344365db7cff8187ff946013d
@kraenhansen kraenhansen deleted the fixing-1128 branch January 9, 2024 18:24
robhogan pushed a commit that referenced this pull request Jan 30, 2024
…ame` (#1136)

Summary:
This fixes #1128 by calling the `resolvePackage` instead of `resolveModulePath` in `resolveHasteName`.
Only `resolvePackage` has the code to resolve package "exports" and it calls `resolveModulePath` as a fallback.

Changelog: [Experimental] When enabled, the `"exports"` field is now considered for Haste packages (which could include local monorepo packages)

Pull Request resolved: #1136

Test Plan: I've added a failing test which passed as the fix got implemented.

Reviewed By: huntie

Differential Revision: D51346769

Pulled By: robhogan

fbshipit-source-id: 8a003d5b147b73d344365db7cff8187ff946013d
@kraenhansen
Copy link
Contributor Author

I'm wondering if we need to update the documentation based on this change 🤔

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 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.

Package Exports not working
4 participants