Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/lemon-buckets-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-router/dev": patch
---

Don't use `"module"` server conditions in Vitest
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,4 @@
- zeromask1337
- zheng-chuang
- zxTomw
- remorses
9 changes: 9 additions & 0 deletions packages/react-router-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,7 @@ export async function getEnvironmentOptionsResolvers(
);
let vite = getVite();


function getBaseOptions({
viteUserConfig,
}: {
Expand Down Expand Up @@ -3544,6 +3545,14 @@ export async function getEnvironmentOptionsResolvers(
// https://vite.dev/guide/migration.html#default-value-for-resolve-conditions
let maybeDefaultServerConditions = vite.defaultServerConditions || [];


if (process.env.VITEST) {
// Vitest will fail to import packages that distribute invalid ESM if the condition "module" is added: https://github.com/remix-run/react-router/issues/13869
maybeDefaultServerConditions = maybeDefaultServerConditions.filter(
(condition) => condition !== "module"
);
}

// There is no helpful export with the default external conditions (see
// https://github.com/vitejs/vite/pull/20279 for more details). So, for now,
// we are hardcording the default here.
Expand Down