-
-
Notifications
You must be signed in to change notification settings - Fork 120
feat!: vite 6 support #1020
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
feat!: vite 6 support #1020
Changes from 4 commits
d32301f
b39e222
dcec9af
e54a2a1
4fb1e5a
47bccb6
4f20ed2
04b1142
bd650b5
dbac1c3
e3a04c5
e1aa2a1
dd7a9cf
6d22716
5fbbe19
641301d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,35 @@ export function svelte(inlineOptions) { | |
return extraViteConfig; | ||
}, | ||
|
||
// @ts-ignore This hook only works in Vite 6 | ||
async configEnvironment(name, config, opts) { | ||
config.resolve ??= {}; | ||
|
||
// Emulate Vite default fallback for `resolve.mainFields` if not set | ||
if (config.resolve.mainFields == null) { | ||
// These exports only exist in Vite 6 | ||
const { defaultClientMainFields, defaultServerMainFields } = await import('vite'); | ||
bluwy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (name === 'client' || opts.isSsrTargetWebworker) { | ||
config.resolve.mainFields = [...defaultClientMainFields]; | ||
} else { | ||
config.resolve.mainFields = [...defaultServerMainFields]; | ||
} | ||
} | ||
config.resolve.mainFields.unshift('svelte'); | ||
|
||
// Emulate Vite default fallback for `resolve.conditions` if not set | ||
if (config.resolve.conditions == null) { | ||
// These exports only exist in Vite 6 | ||
const { defaultClientConditions, defaultServerConditions } = await import('vite'); | ||
if (name === 'client' || opts.isSsrTargetWebworker) { | ||
|
||
config.resolve.conditions = [...defaultClientConditions]; | ||
} else { | ||
config.resolve.conditions = [...defaultServerConditions]; | ||
} | ||
} | ||
config.resolve.conditions.push('svelte'); | ||
}, | ||
|
||
async configResolved(config) { | ||
options = resolveOptions(options, config, cache); | ||
patchResolvedViteConfig(config, options); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { version } from 'vite'; | ||
|
||
/** | ||
* @type {boolean} | ||
*/ | ||
export const isVite6 = version.startsWith('6.'); |
Uh oh!
There was an error while loading. Please reload this page.