-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vite6): re-apply default conditions if using vite 6 or later
Vite 6 no longer applies default conditions when you override resolve.conditions. This PR adds them back conditionally based on the vite version. Fixes #7070
- Loading branch information
thebanjomatic
committed
Jan 15, 2025
1 parent
b526896
commit c0a7cb7
Showing
3 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as vite from 'vite' | ||
|
||
type Vite6Options = typeof vite & Partial<{ | ||
defaultServerConditions?: string[] | ||
}> | ||
|
||
/** | ||
* In Vite 6+, providing a value for resolve.conditions overrides the defaults | ||
* In Vite 5, passing ["node"] will be merged with the defaults | ||
* | ||
* @returns the appropriate conditions array depending on the vite version | ||
* | ||
*/ | ||
export function getDefaultServerConditions() { | ||
return (vite as Vite6Options).defaultServerConditions ?? ['node'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters