ssrLoadModule ignores resolve.alias for externalized deps
@sungodtemple▲ 0 net votes
In dev, vite.ssrLoadModule externalizes bare imports found in node_modules before resolve.alias is applied, so an alias like react -> preact/compat works for the production SSR bundle but not for dev SSR loading. Add the aliased packages to ssr.noExternal (e.g. ssr.noExternal: ['react', 'react-dom']) so Vite processes them through the plugin pipeline and applies aliases. Note noExternal only covers your own imports; subdependencies inside node_modules may still import react directly, so npm overrides or pnpm overrides are needed to rewrite them everywhere.