-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use
context.redirectModulePath
in default resolver, use brows…
…er spec implementation directly Summary: `redirectModulePath`'s API is highly inefficient, often necessitating multiple lookups of package scope - there's no way of knowing from the return value what kind of redirection has occurred, or of using the closest package looked-up, or of providing an already-looked-up package. It does not fit well with implementing `package.json#exports` resolution. This changes the way we use `context.redirectModulePath`, so that the default resolution algorithm absorbs our implementation of `BROWSER_SPEC_REDIRECTION` and doesn't call the user-overridable `context.redirectModulePath`. By using a fixed implementation rather than having to use a potentially-overriden black box, we can apply these redirections in a more structured way. We are *not* seeking to remove support for the `defunctzombie` spec at this point. ## Ecosystem impact From a GH code search, `rnx-kit/metro-resolver-symlinks` is the only OSS package that [calls `context.redirectModulePath`](https://github.com/microsoft/rnx-kit/blob/%40rnx-kit/metro-resolver-symlinks%400.2.1/packages/metro-resolver-symlinks/src/resolver.ts#L58), expecting the default implementation. This change does not break anything there. There are no other callsites in popular repos. Importantly, no public ecosystem uses *override* `redirectModulePath` by providing their own implementation. For users wanting that level of control, overriding or chaining `resolveRequest` still provides it. Changelog: ``` - **[Breaking]**: Don't call `context.redirectModulePath` from default resolver, use a fixed browser field spec implementation. ``` Reviewed By: huntie Differential Revision: D64304411 fbshipit-source-id: 631bfa1fa82f8de68defbd7feea3ac0fe86c66f0
- Loading branch information
1 parent
108383b
commit 5e96d17
Showing
4 changed files
with
54 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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