Open hi-ogawa opened 1 month ago
Vite SSR injects
ERR_MODULE_NOT_FOUND
vitest-dev/vite@95020ab
/packages/vite/src/node/ssr/fetchModule.ts#L78, so it's working there as well.
It only injects modules for externalized dependencies as far as I remember.
I think it might be a good idea to inject the code, but then the message should also be changed to the same one Node.js throws.
Describe the bug
For this code:
On Node
On Vitest
It looks like this was brought up previously in https://github.com/vitest-dev/vitest/issues/326. It doesn't throw during import analysis anymore, but dynamic import error still doesn't have
ERR_MODULE_NOT_FOUND
code (or maybe it did when it's fixed but regression).There are some places injecting
ERR_MODULE_NOT_FOUND
, so maybe it works in some cases, but not the basic case above. https://github.com/vitest-dev/vitest/blob/5e6de2742f329b7e65fe3dff4827b5134d777009/packages/vite-node/src/client.ts#L296-L296Vite SSR injects
ERR_MODULE_NOT_FOUND
https://github.com/vitest-dev/vite/blob/95020ab49e12d143262859e095025cf02423c1d9/packages/vite/src/node/ssr/fetchModule.ts#L78, so it's working there as well.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-53av14?file=src%2Frepro.test.js
System Info
Used Package Manager
npm
Validations