diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index 5b687e27e421..b24a0e06fce8 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -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: { diff --git a/packages/vitest/src/node/plugins/workspace.ts b/packages/vitest/src/node/plugins/workspace.ts index bdffdbe16117..8f4e3c9027e0 100644 --- a/packages/vitest/src/node/plugins/workspace.ts +++ b/packages/vitest/src/node/plugins/workspace.ts @@ -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, },