Fix handling of export map targets with zero or 2+ wildcard characters in package.json imports/exports resolution #1467
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:
Currently, metro-resolver will break if an exports map includes a pattern key whose target does not have exactly one
*
character.This is an incorrect limitation according to the spec - values may have any number (including zero)
*
characters (keys must have no more than one). The spec requires that all occurrences of*
in the matched target are replaced with thepatternMatch
substring of the specified subpath.Worse, we
break
rather thancontinue
on such an "invalid" target, which means the presence of one of these targets can mean we fail resolution before other keys in the export map are tried.This diff implements the spec:
https://nodejs.org/docs/latest/api/esm.html#resolution-algorithm-specification
Reviewed By: huntie
Differential Revision: D70973129
fbshipit-source-id: 68632b68dbc37dc24988cd68529a5cebfcb5a5d3
Stack created with Sapling. Best reviewed with ReviewStack.