-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs: document ssr.resolve.conditions for custom package conditions
#9392
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
Conversation
…onditions Co-authored-by: hi-ogawa <[email protected]>
…onsistent defaults Co-authored-by: hi-ogawa <[email protected]>
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
docs/guide/common-errors.md
Outdated
| ::: tip Why `ssr.resolve.conditions` and not `resolve.conditions`? | ||
| Vitest inherits Vite's configuration convention where: | ||
| - `resolve.conditions` is used for client-side application code (browser environments) | ||
| - `ssr.resolve.conditions` is used for server-side application code (Node.js environments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, transform mode is based on the environment (jsdom/happy-dom use resolve.conditions), custom environments can define transformMode property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b21497b - clarified that transform mode is based on the environment (jsdom/happy-dom use resolve.conditions, node uses ssr.resolve.conditions), and custom environments can define transformMode property.
ssr.resolve.conditions for custom conditions
docs/guide/common-errors.md
Outdated
| ``` | ||
| ::: | ||
|
|
||
| ## Subpath imports with custom conditions are not resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ode behavior Co-authored-by: hi-ogawa <[email protected]>
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
ssr.resolve.conditions for custom conditionsssr.resolve.conditions for custom package conditions
- Clarify Vite environment configuration convention - Fix viteEnvironment value from 'web' to 'client' - Add reference to environment config documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Related
Users cannot resolve package exports or subpath imports with custom conditions in Vitest because
ssr.resolve.conditionsconfiguration is undocumented, leading to confusion about whyresolve.conditionsdoesn't work.Changes
docs/guide/common-errors.mdssr.resolve.conditionsconfigurationresolve.conditionsfor browser-like environments (jsdom, happy-dom, or custom environments withtransformMode: 'web'), andssr.resolve.conditionsfor Node-like environments (node, or custom environments withtransformMode: 'ssr')Example
This works for both package exports and subpath imports. By default, Vitest uses the
nodeenvironment which hastransformMode: 'ssr', so it usesssr.resolve.conditionsfor module resolution.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.