vite
vite copied to clipboard
fix(ssr): exclude `module` condition from ssr node resolve
Description
- closes https://github.com/vitejs/vite/issues/16631
It looks like vite:resolve
plugin's tryNodeResolve
doesn't set overrideConditions
and it will end up including module
as conditions and it's impossible to exclude it from user config:
https://github.com/vitejs/vite/blob/60824f0bc21f10c4530a07d2745bf16761299c78/packages/vite/src/node/plugins/resolve.ts#L1101-L1105
This contracts with ssr module loader's node resolve, which explicitly exclude module
conditions:
https://github.com/vitejs/vite/blob/60824f0bc21f10c4530a07d2745bf16761299c78/packages/vite/src/node/ssr/ssrModuleLoader.ts#L141
todo
- [ ] check if the patch fixes the issue on Vitest
- [ ] just excluding
'module'
when!targetWeb
would be too breaking? - [ ] should investigate cache issue?
- [ ] what does environment api do?