Skip to content

Commit

Permalink
chore: set resolve.mainFields and resolve.conditions for SSR envi…
Browse files Browse the repository at this point in the history
…ronment (#6896)
  • Loading branch information
sapphi-red authored Nov 13, 2024
1 parent 76169a1 commit 251893b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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: {
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

0 comments on commit 251893b

Please sign in to comment.