Open
Description
Documentation is
- Missing
- Outdated
- Confusing
- Not sure?
Explain in Detail
When using Vite 6's experimental Environment API with SSR builds, there's an undocumented requirement that ssr.noExternal
must be configured at the top level of the configuration rather than at the environment level to actually bundle dependencies.
Current Behavior
❌ This doesn't work (dependencies are externalized):
{
environments: {
ssr: {
build: {
noExternal: true, // ← This has no effect
rollupOptions: {
input: 'virtual:my-ssr-entry'
}
}
}
}
}
✅ This works (dependencies are bundled):
{
ssr: {
noExternal: true, // ← Must be at top level
},
environments: {
ssr: {
build: {
rollupOptions: {
input: 'virtual:my-ssr-entry'
}
}
}
}
}
Your Suggestion for Changes
Expected Behavior
When using the Environment API, I would expect noExternal
configuration to work at the environment level:
{
environments: {
ssr: {
noExternal: true, // ← Should work here
build: {
rollupOptions: {
input: 'virtual:my-ssr-entry'
}
}
}
}
}
Reproduction
No response
Steps to reproduce
Reproduction
- Create a Vite plugin that configures an SSR environment:
{
name: 'ssr-plugin',
apply: 'build',
applyToEnvironment: (env) => env.name === 'ssr',
config() {
return {
environments: {
ssr: {
build: {
noExternal: true, // This doesn't work
rollupOptions: {
input: 'my-entry.js'
}
}
}
}
}
}
}
- Build with the Environment API
- Observe that dependencies are externalized (showing
import
statements instead of bundled code) - Move
noExternal: true
to top-levelssr.noExternal
and dependencies get bundled correctly
Environment
- Vite version: 6.3.5
- Node version: [your node version]
- OS: [your OS]
Additional Context
This behavior suggests either:
- Documentation gap: The Environment API docs should clarify which settings remain at the top level vs. environment level
- Potential bug:
noExternal
should be respected when configured at the environment level - Design limitation: Some SSR settings may intentionally remain global rather than per-environment
The current SSR Options documentation only covers the traditional top-level configuration, and the Environment API documentation doesn't specify this interaction.
This issue affects anyone trying to use the new Environment API for SSR builds and expecting environment-scoped configuration to work consistently.