Skip to content

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

@dominikg

Description

@dominikg

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions