Open hi-ogawa opened 1 month ago
Start a new pull request in StackBlitz Codeflow.
It might be related to https://github.com/vitejs/vite/issues/12957#issuecomment-1546664484 (haven't checked the repro deeply)
Thanks for the reference. Yeah, cache issue part of the issue might be related to that.
Another part of the issue is that it doesn't look like it's possible to exclude "module"
condition when using resolveId("some-dep", { ssr: true })
regardless of "some-dep"
is external or not.
Currently ssrLoadModule
API has overrideConditions
trick which happens to just exclude "module"
condition and it behaves nicer in general (though it still gets "module"
condition when directly doing ssrLoadModule("some-dep")
).
I'm making a wip PR in https://github.com/vitejs/vite/pull/16647 to get overrideConditions
into resolveId
flow somehow. Please let me know if this approach isn't right.
On second thought, this didn't feel like a right problem to solve. Probably, what Vitest (or SSR in general) wants to do is to simply exclude 'module'
condition from the default list when doing resolveExportsOrImports
, but this will be probably too breaking:
Describe the bug
I was investigating Vitest issue https://github.com/vitest-dev/vitest/issues/5664 and I came across this confusing behavior while checking the reproduction.
The package in question has following exports and it looks like Vite SSR resolution changes which to pick
...cjs.mjs
or...esm.js
depending onssrLoadModule / resolveId
order.(This is what I made as a simpler repro based on
@emotion/react
https://publint.dev/@emotion/react@11.11.4)I'm not sure yet if this is directly relevant to the referenced Vitest issue, but I thought I'd share it here. I would appreciate if anyone knows whether this is a packaging issue, my incorrect usage, or Vite's resolution issue (or something else).
Reproduction
https://github.com/hi-ogawa/reproductions/blob/main/vitest-5664-mui-emotion-provider/repro-vite.mjs
Steps to reproduce
Running on stackblitz https://stackblitz.com/edit/github-htzuw3?file=repro-vite.mjs
Also comparing with NodeJS's resolution:
System Info
Used Package Manager
pnpm
Logs
No response
Validations