fix: respect bare imports in browser field of package.json #9441
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.
Description
This helps vite respect bare package imports in browser fields of package.json. We (@wittjosiah) discovered this when trying to use
sodium-universal
in a vite app, which asks for this substitution ofsodium-native
:Relevant code in vite seemed to be assuming all such browser values are relative paths and not bare imports
Additional context
We're not sure if we're breaking anything else, and this problem seems related to (but not covered by) the solution in #8709
Let us know how to make this better and we'll get it there, thank you for your time!
Grand merci, Vite team!
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).