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

If a package.json has both "browser" and "module" fields set, vite resolve ignores mainFields order and picks one of them. #15134

Closed
7 tasks done
dominikg opened this issue Nov 24, 2023 · 1 comment · Fixed by #15137

Comments

@dominikg
Copy link
Contributor

Describe the bug

here these fields are evaluated before the mainFields loop below. Leading to mainFields being ignored if they would be sorted in front of "browser".

vite-plugin-svelte sets a custom "mainFields" list with "svelte" as the first entry to resolve svelte components directly, which should take precedence over both "browser" and "module".

Reproduction

https://github.com/benoitf/svelte-issue-app

Steps to reproduce

see sveltejs/vite-plugin-svelte#813 too

[email protected] does not include "browser" in mainfields,
[email protected] added it.

System Info

linux, vite 5

Used Package Manager

yarn

Logs

No response

Validations

@dominikg
Copy link
Contributor Author

i'll be working on a PR to fix this, moving the code that sits outside the loop into a utility function and calling it inside the loop when the browser condition is being checked (instead of the current continue).

@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant