-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Conditional exports can't be active when key is browser
#18012
Comments
The example for reproduction uses Vitest, but in reality, it is not closely related to Vitest; the main issue lies with vite-node.
vite/packages/vite/src/node/plugins/resolve.ts Line 1113 in 5679d81
Based on my debugging results, the handling here seems a bit too tightly coupled with SSR. For other users encountering this issue, you can try setting the |
browser
browser
While I agree Vitest's resolution is confusing at times (other issue I remember is "exports": {
"./foo": {
"browser": "./src/foo.browser.ts",
"node": "./src/foo.node.ts"
}
}, With this, Vitest/Vite automatically adding |
I also noticed this point, and it was precisely because of this that I made some modifications to the corresponding However, based on the latest code, it seems that the issue here has been exacerbated, as users need a configuration that is used in more places to disable this logic. |
Describe the bug
When I use 'browser' as an optional condition for exporting, I cannot correctly import the module.
Reproduction
https://github.com/NWYLZW/issue-vite-conditional-exports
Steps to reproduce
Run
pnpm install
followed bypnpm run test
System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: