Skip to content
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

Merged
merged 16 commits into from
Nov 21, 2024
Merged

feat!: vite 6 support #1020

merged 16 commits into from
Nov 21, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Nov 8, 2024

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.

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) {
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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'

@bluwy bluwy marked this pull request as ready for review November 14, 2024 15:03
@bluwy bluwy changed the title chore: vite 6 ecosystem-ci support feat!: vite 6 support Nov 21, 2024
// be properly used by svelte
if (!isDepExternaled('esm-env', config.ssr?.external ?? [])) {
noExternal.push('esm-env');
}
Copy link
Member

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)

Copy link
Member Author

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 🤔

Copy link
Member

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.

@bluwy bluwy merged commit e3344b4 into main Nov 21, 2024
6 checks passed
@bluwy bluwy deleted the vite-6-beta-support branch November 21, 2024 15:17
This was referenced Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants