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

chore: set resolve.mainFields and resolve.conditions for SSR environment #6896

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ export async function VitestPlugin(
// https://github.com/vitejs/vite/pull/16453
emptyOutDir: false,
},
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore Vite 6 compat
environments: {
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
ssr: {
resolve: {
// by default Vite resolves `module` field, which not always a native ESM module
// setting this option can bypass that and fallback to cjs version
mainFields: [],
conditions: ['node'],
},
},
},
test: {
poolOptions: {
threads: {
Expand Down
12 changes: 12 additions & 0 deletions packages/vitest/src/node/plugins/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ export function WorkspaceVitestPlugin(
),
},
},
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore Vite 6 compat
environments: {
ssr: {
resolve: {
// by default Vite resolves `module` field, which not always a native ESM module
// setting this option can bypass that and fallback to cjs version
mainFields: [],
conditions: ['node'],
},
},
},
test: {
name,
},
Expand Down
Loading