-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
feat!: vite 6 support #1020
Conversation
config.resolve.conditions = [...VITE_CLIENT_RESOLVE_CONDITIONS]; | ||
// These exports only exist in Vite 6 | ||
const { defaultClientConditions, defaultServerConditions } = await import('vite'); | ||
if (name === 'client' || opts.isSsrTargetWebworker) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is name === 'client' a good way to check this? that would assume there can only be one client environment in an app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if there was a tauri app and a web app at the same time, or two different clients?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true, I think it should check the consumer
here, which is the same as Vite internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that a helper vite should expose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's needed imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well how are others going to use these exposed constants then? you'll always want the ones applicable to the environment you are in, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure what you mean. Do you have a pseudocode in mind for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if vite-plugin-svelte needs to check consumer
(where exactly is that?) to decide which of the two constants to pick, wouldn't other plugins have to do the same? at this point it would be better to have a shared place for that logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already updated the code to use consumer
, it is the way Vite wants plugins to do to checks for client or server-based environments. You can get that from config.consumer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I need a combination of config.consumer === 'client'
and name === 'client'
checks to work, since config.consumer
could be undefined but it's documented to fallback to consumer = 'client'
if name
is 'client'
// be properly used by svelte | ||
if (!isDepExternaled('esm-env', config.ssr?.external ?? [])) { | ||
noExternal.push('esm-env'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add warning log that externalizing it will cause trouble?
(with filterable code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally defer this to later if someone stumbles on the issue 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, lets hope noone externalizes it.
Very rough support. There's some things I want to double-check first so marking as draft. But this should pass vite-ecosystem-ci now.