Skip to content

feat: add isSsrTargetWebWorker flag to configEnvironment hook#18620

Merged
sapphi-red merged 1 commit intovitejs:mainfrom
sapphi-red:feat/add-is-ssr-target-webworker-flag-for-config-environment
Nov 14, 2024
Merged

feat: add isSsrTargetWebWorker flag to configEnvironment hook#18620
sapphi-red merged 1 commit intovitejs:mainfrom
sapphi-red:feat/add-is-ssr-target-webworker-flag-for-config-environment

Conversation

@sapphi-red
Copy link
Copy Markdown
Member

Description

This PR adds isSsrTargetWebWorker flag to configEnvironment hook so that plugins can support ssr.target: 'webworker' correctly.
For example, this configEnvironment hook from sveltejs/vite-plugin-svelte#1020 needs to know if ssr.target: 'webworker' is set.
https://github.com/sveltejs/vite-plugin-svelte/blob/dcec9afa2a9b1bfd5fe8f0767cc871a2b144a9d6/packages/vite-plugin-svelte/src/index.js#L71-L81

https://discord.com/channels/804011606160703521/1304311237332697098/1304350474085859338

@sapphi-red sapphi-red added the feat: environment API Vite Environment API label Nov 8, 2024
Copy link
Copy Markdown
Member

@patak-cat patak-cat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok for v6. Do you know how we can get out of it? Do we need another option so this hack isn't needed?
Edit: oh, IIUC, we could just remove it once v5 support is no longer needed. Talking about that, I wonder if svelte will end up doing a clean cut and require Vite 6 soon after we release

Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally still a bit unsure that resolve.conditions now exclusively only applies to client is a nice behaviour, especially that we try to match compat for the environment API, but I don't think it's worth spiraling into that discussion for now 😅 I'll try to test some things locally on my own.

@bluwy
Copy link
Copy Markdown
Member

bluwy commented Nov 12, 2024

Talking about that, I wonder if svelte will end up doing a clean cut and require Vite 6 soon after we release

Dominik is fine with that for vite-plugin-svelte, but we'll likely have to align with sveltekit and the plan could change.

@sapphi-red sapphi-red merged commit 3f5fab0 into vitejs:main Nov 14, 2024
@sapphi-red sapphi-red deleted the feat/add-is-ssr-target-webworker-flag-for-config-environment branch November 14, 2024 02:00
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: environment API Vite Environment API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants